From e8e1b867bb68e41fd86082423c0bfe2213f6fcc2 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Thu, 2 Dec 2021 01:48:27 +0100 Subject: [PATCH] link curl statically --- .gitmodules | 3 +++ Makefile | 15 ++++++++++++--- Readme.md | 10 ++++++++++ src/main.cpp | 3 +++ thirdparty/curl | 1 + 5 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 Readme.md create mode 160000 thirdparty/curl diff --git a/.gitmodules b/.gitmodules index 9457d94..524ce3d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,3 +2,6 @@ path = thirdparty/TAPI url = ssh://gitea@git.okaestne.de:2233/okaestne/TAPI.git branch = wip +[submodule "thirdparty/curl"] + path = thirdparty/curl + url = https://github.com/curl/curl.git diff --git a/Makefile b/Makefile index 666f1af..357a638 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,16 @@ LOGF = $(TAPIF)Log/ LOGO = $(LOGF)Log.o INCLUDES = -I$(LOGF) -I$(TAPIF)include/ $(addprefix -I, $(INCFS)) -LDFLAGS = -lcurl -lseccomp -lcap +LDFLAGS = -lseccomp -lcap + +#dynamic linked curl +#LDFLAGS += -lcurl + +#required for static linked curl +LDFLAGS += -lidn2 -lssl -lcrypto -lz + +#statically linked curl +CURLA = $(TP)curl/libcurl.a SRCFILES = $(shell find $(SRCF) -name "*.cpp") OBJFILES = $(patsubst $(SRCF)%, $(BUILDDIR)%, $(patsubst %.cpp, %.o, $(SRCFILES))) $(LOGO) @@ -39,7 +48,7 @@ INCLUDES += $(addprefix -I, $(SOURCEDIRS)) all: $(NAME) runtest -$(NAME): $(BUILDDIRS) $(DEPF) $(OBJFILES) $(TAPIA) +$(NAME): $(BUILDDIRS) $(DEPF) $(OBJFILES) $(TAPIA) $(CURLA) @echo "Linking $@" @$(CXX) $(CFLAGS) -o $@ $(filter %.o, $^) $(filter %.a, $^) $(LDFLAGS) @@ -69,7 +78,7 @@ clean: $(MAKE) -C $(LOGF) $@ $(MAKE) -C $(TAPIF) $@ -$(NAMETEST): $(BUILDDIRS) $(DEPF) $(TESTF)*.cpp $(OBJFILESTEST) $(TAPIA) +$(NAMETEST): $(BUILDDIRS) $(DEPF) $(TESTF)*.cpp $(OBJFILESTEST) $(TAPIA) $(CURLA) @echo "Compiling tests" $(CXX) -o $@ $(filter %.o, $^) $(filter %.a, $^) $(filter %.cpp, $^) $(CFLAGS) -I$(SRCF) $(INCLUDES) $(LDFLAGS) diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..10d26ad --- /dev/null +++ b/Readme.md @@ -0,0 +1,10 @@ +# Compile curl + +``` +./configure --with-openssl --disable-shared --disable-thread --disable-cookies --disable-doh --disable-manual --disable-proxy --disable-pthreads --disable-socketpair --disable-threaded-resolver --disable-unix-sockets --disable-imap --disable-tftp --disable-mqtt --disable-pop3 --disable-ftp --disable-smtp --disable-rtsp --disable-telnet --disable-smb --disable-gopher --disable-dict + +make + +# create a link +ln -sr lib/.lib/libcurl.a ./ +``` \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 149c285..f29112e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -70,6 +70,8 @@ static bool enableSecurity() { seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(exit), 0); seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(exit_group), 0); seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(rt_sigaction), 0); + seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(rt_sigreturn), 0); // return form a signal + seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(sigreturn), 0); // return from a signal seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(writev), 0); seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(readv), 0); @@ -86,6 +88,7 @@ static bool enableSecurity() { seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(socket), 0); seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(setsockopt), 0); seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(getsockopt), 0); + seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(getsockname), 0); seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(set_robust_list), 0); seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(get_robust_list), 0); seccomp_rule_add(scmp, SCMP_ACT_ALLOW, SCMP_SYS(sendmmsg), 0); diff --git a/thirdparty/curl b/thirdparty/curl new file mode 160000 index 0000000..34294a6 --- /dev/null +++ b/thirdparty/curl @@ -0,0 +1 @@ +Subproject commit 34294a65b29b19ed3699f7cdd7ff98bdf02b1d48