diff --git a/Makefile.in b/Makefile.in index df62443..6fa856a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -11,7 +11,6 @@ ENABLE_REGEX=1 # Enable regex probes USELIBCONFIG=1 # Use libconfig? (necessary to use configuration files) USELIBEV=1 # Use libev? USESYSTEMD= # Make use of systemd socket activation -USELIBBSD?= # Use libbsd (needed to update process name in `ps`) COV_TEST= # Perform test coverage? PREFIX?=/usr BINDIR?=$(PREFIX)/sbin @@ -59,11 +58,6 @@ ifneq ($(strip $(USESYSTEMD)),) CONDITIONAL_TARGETS+=systemd-sslh-generator endif -ifneq ($(strip $(USELIBBSD)),) - LIBS:=$(LIBS) -lbsd - CPPFLAGS+=-DLIBBSD -endif - ifneq ($(strip $(USELIBEV)),) CONDITIONAL_TARGETS+=sslh-ev endif diff --git a/common.c b/common.c index 510173b..d1ab402 100644 --- a/common.c +++ b/common.c @@ -36,7 +36,7 @@ #include #endif -#ifdef LIBBSD +#ifdef HAVE_LIBBSD #include #endif @@ -755,7 +755,7 @@ int get_connection_desc(struct connection_desc* desc, const struct connection *c void set_proctitle_shovel(struct connection_desc* desc, const struct connection *cnx) { -#ifdef LIBBSD +#ifdef HAVE_LIBBSD struct connection_desc d; if (!desc) { diff --git a/config.h.in b/config.h.in index ea327e9..dbc42ab 100644 --- a/config.h.in +++ b/config.h.in @@ -12,4 +12,7 @@ /* libcap support, to use Linux capabilities */ #undef HAVE_LIBCAP +/* libbsd, to change process name */ +#undef HAVE_LIBBSD + #endif diff --git a/configure b/configure index f120ff0..781c6a7 100755 --- a/configure +++ b/configure @@ -3288,6 +3288,47 @@ then : LIBS="$LIBS -lcap" fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for setproctitle in -lbsd" >&5 +printf %s "checking for setproctitle in -lbsd... " >&6; } +if test ${ac_cv_lib_bsd_setproctitle+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_check_lib_save_LIBS=$LIBS +LIBS="-lbsd $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char setproctitle (); +int +main (void) +{ +return setproctitle (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_bsd_setproctitle=yes +else $as_nop + ac_cv_lib_bsd_setproctitle=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_setproctitle" >&5 +printf "%s\n" "$ac_cv_lib_bsd_setproctitle" >&6; } +if test "x$ac_cv_lib_bsd_setproctitle" = xyes +then : + printf "%s\n" "#define HAVE_LIBBSD 1" >>confdefs.h + LIBS="$LIBS -lbsd" +fi + ac_header= ac_cache= for ac_item in $ac_header_c_list diff --git a/configure.ac b/configure.ac index 6a82d8e..cd432c6 100644 --- a/configure.ac +++ b/configure.ac @@ -7,6 +7,7 @@ AC_CONFIG_FILES([Makefile]) AC_CHECK_LIB([wrap], [hosts_ctl], [AC_DEFINE(HAVE_LIBWRAP) LIBS="$LIBS -lwrap" ], []) AC_CHECK_LIB([cap], [cap_get_proc], [AC_DEFINE(HAVE_LIBCAP) LIBS="$LIBS -lcap" ], []) +AC_CHECK_LIB([bsd], [setproctitle], [AC_DEFINE(HAVE_LIBBSD) LIBS="$LIBS -lbsd" ], []) AC_CHECK_HEADERS(linux/landlock.h, AC_DEFINE(HAVE_LANDLOCK), []) AC_OUTPUT diff --git a/sslh-fork.c b/sslh-fork.c index 3418cc5..4cd7888 100644 --- a/sslh-fork.c +++ b/sslh-fork.c @@ -26,7 +26,7 @@ #include "tcp-probe.h" #include "log.h" -#ifdef LIBBSD +#if HAVE_LIBBSD #include #endif @@ -147,7 +147,7 @@ void stop_listeners(int sig) void set_listen_procname(struct listen_endpoint *listen_socket) { -#ifdef LIBBSD +#if HAVE_LIBBSD int res; struct addrinfo addr; struct sockaddr_storage ss; diff --git a/sslh-main.c b/sslh-main.c index 508f86b..160d9fc 100644 --- a/sslh-main.c +++ b/sslh-main.c @@ -30,15 +30,15 @@ #include #endif -#ifdef LIBBSD -#include -#endif - #include "common.h" #include "probe.h" #include "log.h" #include "tcp-probe.h" +#if HAVE_LIBBSD +#include +#endif + #if HAVE_LIBCAP #include #endif @@ -286,7 +286,7 @@ int main(int argc, char *argv[], char* envp[]) int res, num_addr_listen; struct listen_endpoint *listen_sockets; -#ifdef LIBBSD +#if HAVE_LIBBSD setproctitle_init(argc, argv, envp); #endif diff --git a/version.h b/version.h index b8240c5..8bde2a0 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #ifndef VERSION_H #define VERSION_H -#define VERSION "v2.1.4-30-gfabf0a1-dirty" +#define VERSION "v2.1.4-31-gdcfa3fa-dirty" #endif