]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Rename ./configure option --with-libcap to --with-cap (#1140)
authorAmos Jeffries <yadij@users.noreply.github.com>
Fri, 23 Sep 2022 13:26:23 +0000 (13:26 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 23 Sep 2022 16:43:34 +0000 (16:43 +0000)
The 'lib' prefix is supposed to be omitted from --with/--without
names but libcap was not correctly named.

Also, add support for pkg-config library auto-detection.

acinclude/os-deps.m4
compat/os/linux.h
configure.ac
doc/release-notes/release-6.sgml
src/Makefile.am
src/icmp/Makefile.am
src/icmp/pinger.cc
src/tools.cc
test-suite/buildtests/layer-01-minimal.opts
test-suite/buildtests/layer-02-maximus.opts
test-suite/buildtests/layer-04-noauth-everything.opts

index d0b36f9854473f4d0269206564ac2ba50f5d44a1..7c86ed2781628b3453dc703e3a3d47f37ce85208 100644 (file)
@@ -81,8 +81,8 @@ int main(int argc, char **argv)
 
 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_CHECK_HEADERS([sys/capability.h])
   AC_CACHE_CHECK([for operational libcap2 headers],
                  squid_cv_sys_capability_works,
     AC_LINK_IFELSE([AC_LANG_PROGRAM([[
index 6a36fe604d7561c4faa765965f8a9d2441aaa45b..a5828b62f574a0bb3be5a24cf2d72c27dab73581 100644 (file)
 #include <netinet/in.h>
 #endif
 
-/*
- * sys/capability.h is only needed in Linux apparently.
- *
- * HACK: LIBCAP_BROKEN Ugly glue to get around linux header madness colliding with glibc
- */
-#if HAVE_SYS_CAPABILITY_H
-
-#if LIBCAP_BROKEN
-#undef _POSIX_SOURCE
-#define _LINUX_TYPES_H
-#define _LINUX_FS_H
-typedef uint32_t __u32;
-#endif
-
-#include <sys/capability.h>
-#endif /* HAVE_SYS_CAPABILITY_H */
-
 /*
  * glob.h is provided by GNU on Linux and contains some unavoidable preprocessor
  * logic errors in its 64-bit definitions which are hit by non-GCC compilers.
index 83cff9d559c2b9bca26c64bdcd35ccec85bac51d..ff5ef3495103aa3311444136ab6bd946213ad040 100644 (file)
@@ -2653,39 +2653,33 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 dnl Check for special functions
 AC_FUNC_ALLOCA
 
-
-# TODO: remove this 'lib' prefix to match coding standard
-SQUID_AUTO_LIB(libcap,[Linux capabilities],[LIBCAP])
-AS_IF([test "x$with_libcap" != "xno"],[
+SQUID_AUTO_LIB(cap,[Linux capabilities],[LIBCAP])
+AS_IF([test "x$with_cap" != "xno"],[
+  SQUID_STATE_SAVE(squid_libcap_state)
   CXXFLAGS="$LIBCAP_CFLAGS $CXXFLAGS"
   LDFLAGS="$LIBCAP_PATH $LDFLAGS"
-  # cap_clear_flag is the most recent libcap function we require
-  AC_CHECK_HEADERS(sys/capability.h)
-  AC_CHECK_LIB(cap, cap_clear_flag)
+  PKG_CHECK_MODULES([LIBCAP],[libcap >= 2.09],[],[
+    # cap_clear_flag is the most recent libcap function we require
+    AC_CHECK_LIB([cap],[cap_clear_flag],[LIBCAP_LIBS="$LIBCAP_LIBS -lcap"])
+  ])
   SQUID_CHECK_FUNCTIONAL_LIBCAP2
-
-  # if it can't be supported..
-  AS_IF([test "x$ac_cv_header_sys_capability_h" = "xno" -o \
-     "x$ac_cv_lib_cap_cap_clear_flag" = "xno"],[
-    # and it was forced on: error
-    AS_IF([test "x$with_libcap" = "xyes"],[
-      AC_MSG_ERROR([libcap forced enabled but not available or not usable, requires libcap-2.09 or later])
-    ],[
-      # or it can't be supported: disable
-      with_libcap=no
-    ])
+  AC_MSG_NOTICE([libcap headers are ok: $squid_cv_sys_capability_works])
+  AS_IF([test "x$squid_cv_sys_capability_works" = "xno"],[LIBCAP_LIBS=""])
+  SQUID_STATE_ROLLBACK(squid_libcap_state)
+
+  AS_IF([test "x$LIBCAP_LIBS" != "x"],[
+    with_cap=yes
+    CPPFLAGS="$LIBCAP_CFLAGS $CPPFLAGS"
+    LIBCAP_LIBS="$LIBCAP_PATH $LIBCAP_LIBS"
+    AC_DEFINE(USE_LIBCAP,1,[Linux capabilities library support])
+  ],[test "x$with_cap" = "xyes"],[
+    AC_MSG_ERROR([Required library libcap not found])
   ],[
-    with_libcap=yes
+    AC_MSG_NOTICE([Library libcap not found])
+    with_cap=no
   ])
 ])
-
-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_MSG_NOTICE([Linux capabilities support enabled: ${with_cap} ${LIBCAP_LIBS}])
 
 dnl Check for needed libraries
 AC_SEARCH_LIBS([gethostbyname],[nsl resolv bind])
@@ -3149,13 +3143,13 @@ 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])
-AS_IF([test "x$enable_linux_netfilter" = "xyes" -a "x$with_libcap" != "xyes"],[
+AS_IF([test "x$enable_linux_netfilter" = "xyes" -a "x$with_cap" != "xyes"],[
   AC_MSG_WARN([Missing needed capabilities (libcap 2.09+) for TPROXY])
   AC_MSG_WARN([Linux Transparent Proxy (version 4+) support WILL NOT be enabled])
   AC_MSG_WARN([Reduced support to NAT Interception Proxy])
   # AC_DEFINEd later
 ])
-AS_IF([test "x$with_netfilter_conntrack" = "xyes" -a "x$with_libcap" != "xyes"],[
+AS_IF([test "x$with_netfilter_conntrack" = "xyes" -a "x$with_cap" != "xyes"],[
   AC_MSG_WARN([Missing needed capabilities (libcap 2.09+) for netfilter mark support])
   AC_MSG_WARN([Linux netfilter marking support WILL NOT be enabled])
   with_netfilter_conntrack=no
index 8a6dfd45b88edc3e8015dc53a71ee42ad3538ae2..65c5daeb2e90c6be91e5f808166004b61f407487 100644 (file)
@@ -103,6 +103,9 @@ This section gives an account of those changes in three categories:
 <sect1>New options<label id="newoptions">
 <p>
 <descrip>
+       <tag>--with-cap</tag>
+       <p>Replacement for <em>--with-libcap</em>.
+
        <tag>--with-xml2</tag>
        <p>Replacement for <em>--with-libxml2</em>.
 
@@ -126,6 +129,9 @@ This section gives an account of those changes in three categories:
        <tag>--disable-loadable-modules</tag>
        <p>This option was performing the same duties as <em>--disable-shared</em>.
 
+       <tag>--with-libcap</tag>
+       <p>Replaced by <em>--with-cap</em>.
+
        <tag>--with-libxml2</tag>
        <p>Replaced by <em>--with-xml2</em>.
 
index 0196718307959dbdeaf73daa769e3977ea02c89a..58c576dc29fab457155e118599dcd4bf0cffc362 100644 (file)
@@ -525,6 +525,7 @@ squid_LDADD = \
        $(top_builddir)/lib/libmisccontainers.la \
        $(top_builddir)/lib/libmiscencoding.la \
        $(top_builddir)/lib/libmiscutil.la \
+       $(LIBCAP_LIBS) \
        $(SSLLIB) \
        $(EPOLL_LIBS) \
        $(MINGW_LIBS) \
@@ -1957,6 +1958,7 @@ tests_test_http_range_LDADD = \
        $(top_builddir)/lib/libmisccontainers.la \
        $(top_builddir)/lib/libmiscencoding.la \
        $(top_builddir)/lib/libmiscutil.la \
+       $(LIBCAP_LIBS) \
        $(REGEXLIB) \
        $(SSLLIB) \
        $(KRB5LIBS) \
@@ -2341,6 +2343,7 @@ tests_testHttpRequest_LDADD = \
        $(top_builddir)/lib/libmisccontainers.la \
        $(top_builddir)/lib/libmiscencoding.la \
        $(top_builddir)/lib/libmiscutil.la \
+       $(LIBCAP_LIBS) \
        $(REGEXLIB) \
        $(SSLLIB) \
        $(KRB5LIBS) \
@@ -2639,6 +2642,7 @@ tests_testCacheManager_LDADD = \
        $(top_builddir)/lib/libmisccontainers.la \
        $(top_builddir)/lib/libmiscencoding.la \
        $(top_builddir)/lib/libmiscutil.la \
+       $(LIBCAP_LIBS) \
        $(REGEXLIB) \
        $(SSLLIB) \
        $(KRB5LIBS) \
index e6bed7d6322794fa89fa8ef63a12861ef63bed79..fe7a8befd5fb53f30ec43768d6220c985f4f6d40 100644 (file)
@@ -62,6 +62,7 @@ pinger_LDADD=\
        $(top_builddir)/src/time/libtime.la \
        $(top_builddir)/src/base/libbase.la \
        $(top_builddir)/src/mem/libminimal.la \
+       $(LIBCAP_LIBS) \
        $(COMPAT_LIB) \
        $(SSLLIB) \
        $(XTRA_LIBS)
index 4322262937bea4c6cabaa6c8c6400e3df429eb71..586fbfcc8a95687226163116419aec2d2085e45e 100644 (file)
 #include "ip/tools.h"
 #include "time/gadgets.h"
 
+#if HAVE_SYS_CAPABILITY_H
+#include <sys/capability.h>
+#endif
+
 #if _SQUID_WINDOWS_
 
 #if HAVE_WINSOCK2_H
@@ -58,6 +62,7 @@
 #include <winsock.h>
 #endif
 #include <process.h>
+
 #include "fde.h"
 
 #define PINGER_TIMEOUT 5
index 5c9bfb029f794ecdb7d9591c692cec8352d8c5fb..1b6956f6b8f1891e77e9a01de65cca3ad2a16963 100644 (file)
@@ -33,6 +33,9 @@
 #include "wordlist.h"
 
 #include <cerrno>
+#if HAVE_SYS_CAPABILITY_H
+#include <sys/capability.h>
+#endif
 #if HAVE_SYS_PRCTL_H
 #include <sys/prctl.h>
 #endif
index c12b5a28e29cc5a0b3bd51499d5bdc9254c272d6..2cad1531989ea16d5742f3743501128e79233fe5 100644 (file)
@@ -97,6 +97,7 @@ DISTCHECK_CONFIGURE_FLAGS=" \
  \
        --without-pthreads \
        --without-aio \
+       --without-cap \
        --without-dl \
        --without-large-files \
        --without-nettle \
index 55789faf981d638550685d79bc3ebd11e4993f6d..46c7fdd25ee7cb92b098d14dc38f8f9e9bea1eea 100644 (file)
@@ -44,6 +44,7 @@ MAKETEST="distcheck"
 #   --with-valgrind-debug \
 #   --with-gnutls \
 #   --with-tdb \
+#   --with-cap \
 #
 #   --enable-cpu-profiling \  Requires CPU support.
 #
index 0e9d5446e1ef9c56f9d0577ea48fd988e5c8cd5b..a5e72c308fc2cf8cc96114c802027529001701ba 100644 (file)
@@ -33,6 +33,7 @@ MAKETEST="distcheck"
 #   --with-openssl=PATH \
 #   --with-po2html=PATH \
 #   --with-tags=TAGS \
+#   --with-cap \
 #
 #      Following features require special support from other optional packages.
 #      We can't test them automatically everywhere without detecting those