Skip to contentSkip to conversation

Merge nfct tool into conntrackd

PATCH New Phil Sutter 1 participant 1 message Jan 26, 2022 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 Merge nfct tool into conntrackd

Both programs dynamically load ct_helper libraries but since conntrackd provides symbols some libraries need and nfct does not, the latter must rely on lazy binding. This in turn is problematic with some distributions' security policies.

One could export those symbols into a library and link nfct against it and what else is missing, but this solution is much simpler.

---
 configure.ac    |  3 ---
 include/nfct.h  |  2 ++
 src/Makefile.am | 42 +++++++++++++++---------------------------
 src/main.c      |  5 +++++
 src/nfct.c      |  2 +-
 5 files changed, 23 insertions(+), 31 deletions(-)
configure.ac +0 -3
index b12b722a3396d..58d90da740a34 100644
@@ -77,9 +77,6 @@ AC_CHECK_HEADERS([linux/capability.h],, [AC_MSG_ERROR([Cannot find linux/capabib
 AC_CHECK_HEADERS(arpa/inet.h)
 AC_CHECK_FUNCS(inet_pton)
 
-# Let nfct use dlopen() on helper libraries without resolving all symbols.
-AX_CHECK_LINK_FLAG([-Wl,-z,lazy], [AC_SUBST([LAZY_LDFLAGS], [-Wl,-z,lazy])])
-
 if test ! -z "$libdir"; then
 	MODULE_DIR="\\\"$libdir/conntrack-tools/\\\""
 	CFLAGS="$CFLAGS -DCONNTRACKD_LIB_DIR=$MODULE_DIR"
include/nfct.h +2 -0
index bfffdd6fa909f..103fcfab9f954 100644
@@ -43,4 +43,6 @@ int nfct_mnl_talk(struct mnl_socket *nl, struct nlmsghdr *nlh,
 		  int (*cb)(const struct nlmsghdr *nlh, void *data),
 		  void *data);
 
+int nfct_main(int argc, char *argv[]);
+
 #endif
src/Makefile.am +15 -27

68 lines not on this page · raw message

src/main.c +5 -0
index 31e0eed950b48..63e2a8c51c3fd 100644
@@ -20,6 +20,7 @@
 #include "conntrackd.h"
 #include "log.h"
 #include "helper.h"
+#include "nfct.h"
 #include "systemd.h"
 #include "resync.h"
 
@@ -32,6 +33,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <limits.h>
+#include <libgen.h>
 
 struct ct_general_state st;
 struct ct_state state;
@@ -126,6 +128,9 @@ int main(int argc, char *argv[])
 	struct utsname u;
 	int version, major, minor;
 
+	if (!strcmp(basename(argv[0]), "nfct"))
+		return nfct_main(argc, argv);
+
 	/* Check kernel version: it must be >= 2.6.18 */
 	if (uname(&u) == -1) {
 		dlog(LOG_ERR, "Can't retrieve kernel version via uname()");
src/nfct.c +1 -1
index 27841be38e961..09527a8dede9a 100644
@@ -119,7 +119,7 @@ static int nfct_subsys_error(char *argv[])
 	return EXIT_FAILURE;
 }
 
-int main(int argc, char *argv[])
+int nfct_main(int argc, char *argv[])
 {
 	int subsys, cmd, ret = 0;
 	struct nfct_extension *ext;
Signature · 1 line
2.34.1