From 8cb219bfdc0ae3763e19a0f96511f32f9b06e243 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 30 Nov 2009 00:41:05 +0100 Subject: [PATCH] Check for capabilities support via libcap-ng --- Makefile.am | 5 +++-- bootstrap-configure | 1 + configure.ac | 10 ++++++++++ src/main.c | 8 ++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index d4c26a9..e63e368 100644 --- a/Makefile.am +++ b/Makefile.am @@ -58,7 +58,7 @@ src_connmand_SOURCES += src/udev-compat.c endif src_connmand_LDADD = $(builtin_libadd) \ - @GLIB_LIBS@ @DBUS_LIBS@ @UDEV_LIBS@ -ldl + @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ @UDEV_LIBS@ -ldl src_connmand_LDFLAGS = -Wl,--export-dynamic -Wl,--version-script=src/connman.ver @@ -83,7 +83,8 @@ build_plugindir = $(plugindir) build_scriptdir = $(scriptdir) endif -AM_CFLAGS = @UDEV_CFLAGS@ @NETLINK_CFLAGS@ @DBUS_CFLAGS@ \ +AM_CFLAGS = @UDEV_CFLAGS@ @NETLINK_CFLAGS@ @CAPNG_CFLAGS@ \ + @DBUS_CFLAGS@ @GLIB_CFLAGS@ $(builtin_cflags) \ @GLIB_CFLAGS@ $(builtin_cflags) \ -DCONNMAN_PLUGIN_BUILTIN \ -DSTATEDIR=\""$(statedir)"\" \ diff --git a/bootstrap-configure b/bootstrap-configure index 706f043..3132115 100755 --- a/bootstrap-configure +++ b/bootstrap-configure @@ -32,5 +32,6 @@ fi --enable-iwmx \ --enable-iospm \ --enable-polkit=builtin \ + --enable-capng \ --enable-client \ --enable-tools $* diff --git a/configure.ac b/configure.ac index 3969aa5..9709b9e 100644 --- a/configure.ac +++ b/configure.ac @@ -332,6 +332,16 @@ AC_ARG_ENABLE(fake, AC_HELP_STRING([--enable-fake], [enable fake device support]), [enable_fake=${enableval}]) AM_CONDITIONAL(FAKE, test "${enable_fake}" = "yes") +AC_ARG_ENABLE(capng, AC_HELP_STRING([--enable-capng], + [enable capabilities support]), [enable_capng=${enableval}]) +if (test "${enable_capng}" = "yes"); then + PKG_CHECK_MODULES(CAPNG, libcap-ng, dummy=yes, + AC_MSG_ERROR(Capabilities library is required)) + AC_SUBST(CAPNG_CFLAGS) + AC_SUBST(CAPNG_LIBS) + AC_DEFINE(HAVE_CAPNG, 1, [Define to 1 if you have capabilities library.]) +fi + AC_ARG_ENABLE(udev, AC_HELP_STRING([--disable-udev], [don't use udev support even if available]), [enable_udev=${enableval}]) diff --git a/src/main.c b/src/main.c index 312b823..327eb24 100644 --- a/src/main.c +++ b/src/main.c @@ -34,6 +34,10 @@ #include +#ifdef HAVE_CAPNG +#include +#endif + #include "connman.h" static GMainLoop *main_loop = NULL; @@ -109,6 +113,10 @@ int main(int argc, char *argv[]) struct sigaction sa; mode_t old_umask; +#ifdef HAVE_CAPNG + /* Drop capabilities */ +#endif + #ifdef NEED_THREADS if (g_thread_supported() == FALSE) g_thread_init(NULL); -- 2.7.4