])
]) # Knot DNS utilities dependencies
+AS_IF([test "$enable_daemon" = "yes"], [
+ PKG_CHECK_MODULES([cap_ng], [cap-ng], [enable_cap_ng=yes], [
+ enable_cap_ng=no
+ AC_CHECK_HEADER([cap-ng.h], [
+ save_LIBS="$LIBS"
+ AC_SEARCH_LIBS([capng_apply], [cap-ng], [
+ enable_cap_ng=yes
+ cap_ng_LIBS="$ac_cv_search_capng_apply"
+ AC_SUBST([cap_ng_LIBS])
+ ])
+ LIBS="$save_LIBS"
+ ])
+ ])
+], [
+ enable_cap_ng=no
+ cap_ng_LIBS=
+])
+
+AS_IF([test "$enable_cap_ng" = yes],
+ [AC_DEFINE([ENABLE_CAP_NG], [1], [POSIX capabilities available])]
+)
+
AC_SEARCH_LIBS([pow], [m])
AC_SEARCH_LIBS([pthread_create], [pthread], [], [AC_MSG_ERROR([pthreads not found])])
AC_SEARCH_LIBS([dlopen], [dl])
AC_SEARCH_LIBS([clock_gettime], [rt])
-AC_SEARCH_LIBS([capng_apply], [cap-ng])
# Checks for header files.
AC_HEADER_RESOLV
-AC_CHECK_HEADERS_ONCE([cap-ng.h pthread_np.h sys/uio.h])
+AC_CHECK_HEADERS_ONCE([pthread_np.h sys/uio.h])
# Checks for optional library functions.
AC_CHECK_FUNCS([accept4 clock_gettime fgetln getline initgroups malloc_trim \
Utilities with Dnstap: ${enable_dnstap}
MaxMind DB support: ${enable_maxminddb}
Systemd integration: ${enable_systemd}
+ POSIX capabilities ${enable_cap_ng}
PKCS #11 support: ${enable_pkcs11}
Ed25519 support: ${enable_ed25519}
Code coverage: ${enable_code_coverage}
knotc_LDADD = libcontrib.la libknotd.la libknotus.la $(libedit_LIBS)
knotc_LDFLAGS = $(AM_LDFLAGS) -rdynamic
knotd_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAG_VISIBILITY) $(liburcu_CFLAGS)
-knotd_LDADD = $(malloc_LIBS) libcontrib.la libknotd.la $(liburcu_LIBS)
+knotd_LDADD = $(malloc_LIBS) libcontrib.la libknotd.la $(liburcu_LIBS) \
+ $(cap_ng_LIBS)
knotd_LDFLAGS = $(AM_LDFLAGS) -rdynamic
if HAVE_UTILS
#include <sys/stat.h>
#include <urcu.h>
-#ifdef HAVE_CAP_NG_H
+#ifdef ENABLE_CAP_NG
#include <cap-ng.h>
-#endif /* HAVE_CAP_NG_H */
+#endif
#ifdef ENABLE_SYSTEMD
#include <systemd/sd-daemon.h>
/*! \brief Drop POSIX 1003.1e capabilities. */
static void drop_capabilities(void)
{
-#ifdef HAVE_CAP_NG_H
+#ifdef ENABLE_CAP_NG
/* Drop all capabilities. */
if (capng_have_capability(CAPNG_EFFECTIVE, CAP_SETPCAP)) {
capng_clear(CAPNG_SELECT_BOTH);
} else {
log_info("process not allowed to set capabilities, skipping");
}
-#endif /* HAVE_CAP_NG_H */
+#endif /* ENABLE_CAP_NG */
}
/*! \brief Event loop listening for signals and remote commands. */