From: Amos Jeffries Date: Fri, 23 Sep 2022 13:26:23 +0000 (+0000) Subject: Rename ./configure option --with-libcap to --with-cap (#1140) X-Git-Tag: SQUID_6_0_1~97 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=59eac9076ef5d35faf306c4614872c2f2beef62c;p=thirdparty%2Fsquid.git Rename ./configure option --with-libcap to --with-cap (#1140) 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. --- diff --git a/acinclude/os-deps.m4 b/acinclude/os-deps.m4 index d0b36f9854..7c86ed2781 100644 --- a/acinclude/os-deps.m4 +++ b/acinclude/os-deps.m4 @@ -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([[ diff --git a/compat/os/linux.h b/compat/os/linux.h index 6a36fe604d..a5828b62f5 100644 --- a/compat/os/linux.h +++ b/compat/os/linux.h @@ -44,23 +44,6 @@ #include #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 -#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. diff --git a/configure.ac b/configure.ac index 83cff9d559..ff5ef34951 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/doc/release-notes/release-6.sgml b/doc/release-notes/release-6.sgml index 8a6dfd45b8..65c5daeb2e 100644 --- a/doc/release-notes/release-6.sgml +++ b/doc/release-notes/release-6.sgml @@ -103,6 +103,9 @@ This section gives an account of those changes in three categories: New options