]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Refactored libcap support.
authorFrancesco Chemolli <kinkie@squid-cache.org>
Fri, 9 Jul 2010 11:45:58 +0000 (13:45 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Fri, 9 Jul 2010 11:45:58 +0000 (13:45 +0200)
Improved message text for SQUID_DEFINE_BOOL autoconf macro.

acinclude/os-deps.m4
acinclude/squid-util.m4
configure.in

index cd3ab1380396d6b55230a4e1d35980b5f971cdf8..ff88f448ab07bcd308760999674524c97690f14b 100644 (file)
@@ -135,3 +135,22 @@ int main(int argc, char **argv)
       ]])],[squid_cv_epoll_works=yes],[squid_cv_epoll_works=no],[]))
 
 ]) dnl SQUID_CHECK_EPOLL
+
+dnl check that we have functional libcap2 headers
+dnl sets squid_cv_sys_capability_works to "yes" or "no"
+AC_DEFUN([SQUID_CHECK_FUNCTIONAL_LIBCAP2],[
+  AC_CACHE_CHECK([for operational libcap2 headers], 
+                 squid_cv_sys_capability_works,
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/capability.h>
+]], [[
+    capget(NULL, NULL);
+    capset(NULL, NULL);
+]])],
+   [squid_cv_sys_capability_works=yes],
+   [squid_cv_sys_capability_works=no])
+  )
+])
+
index 420e9bceeebd6762ab5b0357b35cf552fa9fba90..de936cd8e8246a3f2c39151c355eea1b59117edb 100644 (file)
@@ -163,7 +163,7 @@ squid_tmp_define=""
 case "$2" in 
   yes|true|1) squid_tmp_define="1" ;;
   no|false|0|"") squid_tmp_define="0" ;;
-  *) AC_MSG_ERROR([SQUID_DEFINE[]_BOOL: unrecognized value: '$2']) ;;
+  *) AC_MSG_ERROR([SQUID_DEFINE[]_BOOL: unrecognized value for $1: '$2']) ;;
 esac
 ifelse([$#],3, 
   [AC_DEFINE_UNQUOTED([$1], [$squid_tmp_define],[$3])],
index c3aec948f61835b3f2a2b530df3527602aa4330a..db6103a5c88957889d0e50151f749044cb9b52a2 100644 (file)
@@ -2486,48 +2486,40 @@ AC_CHECK_TYPE(socklen_t,AC_DEFINE(HAVE_SOCKLEN_T,1,[socklen_t is defined by the
 #endif])
 
 dnl Check for libcap header (assume its not broken unless 
-use_libcap=auto
-AC_ARG_WITH(libcap, AS_HELP_STRING([--without-libcap],[disable usage of Linux capabilities library to control privileges]),
-[ if test "x$withval" = "xyes" ; then
-    AC_MSG_RESULT(libcap forced enabled)
-    use_libcap=yes
-  else
-    AC_MSG_RESULT(libcap forced disabled)
-    use_libcap=no
-  fi
-])
-if test "x$use_libcap" != "xno"; then
+AC_ARG_WITH(libcap, AS_HELP_STRING([--without-libcap],
+       [disable usage of Linux capabilities library to control privileges]), [
+SQUID_YESNO([$withval],[unrecognized argument to --without-libcap: $withval])
+],[with_libcap=auto])
+
+if test "x$with_libcap" != "xno"; then
   # cap_clear_flag is the most recent libcap function we require
+  AC_CHECK_HEADERS(sys/capability.h)
   AC_CHECK_LIB(cap, cap_clear_flag)
-  if test "x$ac_cv_lib_cap_cap_clear_flag" = xyes; then
-    use_libcap=yes
-  else
-    if test "x$use_libcap" = "xyes"; then
+  SQUID_CHECK_FUNCTIONAL_LIBCAP2
+
+  # if it can't be supported..
+  if test "x$ac_cv_header_sys_capability_h" = "no" -o \
+    "x$ac_cv_lib_cap_cap_clear_flag" = "no"; then
+    # and it was forced on: error
+    if "x$with_libcap" = "yes" ; then
       AC_MSG_ERROR([libcap forced enabled but not available or not usable, requires libcap-2.09 or later])
     fi
-    use_libcap=no
+    # with_libcap is "auto"; it can't be supported. Disable.
+    with_libcap=no
+  else
+    # header and lib are ok, we support
+    with_libcap=yes
   fi
-fi
 
-if test "x$use_libcap" = "xyes"; then
-  AC_DEFINE(USE_LIBCAP, 1, [use libcap to set capabilities required for TPROXY])
-  dnl Check for libcap headader breakage.
-  AC_CHECK_HEADERS(sys/capability.h)
-  AC_CACHE_CHECK([for operational libcap2 headers], squid_cv_sys_capability_works,
-    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
-#include <stdlib.h>
-#include <stddef.h>
-#include <sys/capability.h>
-]], [[
-capget(NULL, NULL);
-capset(NULL, NULL);
-                   ]])],[squid_cv_sys_capability_works=yes],[squid_cv_sys_capability_works=no])
-  )
-  if test x$squid_cv_sys_capability_works != xyes; then
-    AC_DEFINE([LIBCAP_BROKEN],1,[if libcap2 headers are broken and clashing with glibc])
-  fi
 fi
 
+SQUID_DEFINE_BOOL(USE_LIBCAP,$with_libcap,
+   [use libcap to set capabilities required for TPROXY])
+AC_MSG_NOTICE([libcap support enabled: $with_libcap])
+SQUID_DEFINE_BOOL(LIBCAP_BROKEN,${squid_cv_sys_capability_works:=no},
+   [libcap2 headers are broken and clashing with glibc])
+AC_MSG_NOTICE([libcap2 headers are ok: $squid_cv_sys_capability_works])
+
 
 AC_CHECK_TYPE(mtyp_t,AC_DEFINE(HAVE_MTYP_T,1,[mtyp_t is defined by the system headers]),,[#include <sys/types.h>
 #include <sys/ipc.h>
@@ -3180,7 +3172,7 @@ SQUID_DEFINE_BOOL(LINUX_NETFILTER,$enable_linux_netfilter,
 
 dnl Netfilter TPROXY depends on libcap but the NAT parts can still work.
 AC_MSG_NOTICE([Support for Netfilter-based interception proxy requested: $enable_linux_netfilter])
-if test "$enable_linux_netfilter" = "yes" && test "$use_libcap" != "yes" ; then
+if test "$enable_linux_netfilter" = "yes" && test "$with_libcap" != "yes" ; then
     AC_MSG_WARN([Missing needed capabilities (libcap or libcap2) for TPROXY])
     AC_MSG_WARN([Linux Transparent Proxy support WILL NOT be enabled])
     AC_MSG_WARN([Reduced support to Interception Proxy])