summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2020-11-19 14:29:56 +0000
committerRussell King <rmk+kernel@armlinux.org.uk>2020-11-19 14:29:56 +0000
commit94e91aa0e60551ebfe1c236176f455761909df7c (patch)
treeec47b04c4b85494b7a359b60ef6abc77623d41a8
parent9c7fd727cf375974894624674a561c0adf12aa6e (diff)
Update libcap support
-rw-r--r--configure.ac6
-rw-r--r--src/Makefile.in2
-rw-r--r--src/ircd.c7
3 files changed, 10 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index 1fb6f61..95019eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,6 +59,12 @@ AC_ARG_ENABLE(libgeoip,
[AC_SEARCH_LIBS(GeoIP_id_by_ipnum_v6_gl, GeoIP,
[AC_DEFINE(HAVE_LIBGEOIP, 1, [Define to 1 if libGeoIP (-lGeoIP) is available.])])])], [])
+AC_ARG_ENABLE(libcap,
+ [AS_HELP_STRING([--disable-libcap],[Disable libcap support])], [],
+ [AC_CHECK_HEADER(sys/capability.h,
+ [AC_SEARCH_LIBS(cap_from_text, cap,
+ [AC_DEFINE(HAVE_LIBCAP, 1, [Define to 1 if libcap (-lcap) is available.])])])], [])
+
AX_CHECK_OPENSSL
AC_ARG_ENABLE(assert, AS_HELP_STRING([--enable-assert],
diff --git a/src/Makefile.in b/src/Makefile.in
index c9990c8..d758c1c 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -356,7 +356,7 @@ AUTOMAKE_OPTIONS = foreign
AM_YFLAGS = -d
AM_CPPFLAGS = $(LTDLINCL) -I$(top_srcdir)/include
ircd_LDFLAGS = -export-dynamic
-ircd_LDADD = $(LIBLTDL) -lcap
+ircd_LDADD = $(LIBLTDL)
ircd_DEPENDENCIES = $(LTDLDEPS)
ircd_SOURCES = channel.c \
channel_mode.c \
diff --git a/src/ircd.c b/src/ircd.c
index 72c6d40..abd3997 100644
--- a/src/ircd.c
+++ b/src/ircd.c
@@ -23,7 +23,6 @@
* \brief Starts up and runs the ircd.
* \version $Id$
*/
-#define USE_LINUX_CAP
#define _GNU_SOURCE
#include "stdinc.h"
#include "s_user.h"
@@ -62,7 +61,7 @@
#include "conf_db.h"
#include "conf_class.h"
-#ifdef USE_LINUX_CAP
+#ifdef HAVE_LIBCAP
#include <pwd.h>
#include <grp.h>
#include <sys/prctl.h>
@@ -465,7 +464,7 @@ ssl_init(void)
#endif /* HAVE_LIBCRYPTO */
}
-#ifdef USE_LINUX_CAP
+#ifdef HAVE_LIBCAP
/* This drops ALL privs except for CAP_NET_BIND_SERVICE */
static int drop_priv(char *user, char *group)
{
@@ -530,7 +529,7 @@ main(int argc, char *argv[])
/* Check to see if the user is running us as root, which is a nono */
if (geteuid() == 0)
{
-#ifdef USE_LINUX_CAP
+#ifdef HAVE_LIBCAP
if (drop_priv(getenv("IRCD_USER"), getenv("IRCD_GROUP"))) {
fprintf(stderr, "Unable to drop capabilities\n");
return -1;