]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
autoconf upgrade: basic_auth helpers (and Bug 3793)
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 1 May 2013 06:59:12 +0000 (00:59 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 1 May 2013 06:59:12 +0000 (00:59 -0600)
Convert the basic_auth bundled helpers from using bash to m4 scripts
when testgn which helpers are able to be built.

This conversion allows us to leverage existing information found by
./configure in the helper test scritps, and to de-duplicate and simplify
many of the testing checks.

This required shuffling the SASL checks into a custom macro, which is
altered from a halting ERROR when SASL is absent to a softer WARNING,
but prevents the SASL helpers building - which the old checks did not
guarantee. Resolving Bug 3793.

The nature of m4 macros adds two small long term issues. Both
well-known issues with m4_include() expansion:
 * the macro is expanded in-place without scoping separation.
 So any brokenness in the child scripts will be a little harder to
 identify and may result in breakage of modues other than the one whose
 child script was the cause.

 * the macro takes literal arguments without variable expansion.
 So a "full" path relative to the main configure.ac script is required
 in every include. Meaning the modules.m4 file cannot simply
 sub-include using the $helper script variable, but must be a full
 expansion of the modules set.

31 files changed:
acinclude/squid-util.m4
configure.ac
helpers/basic_auth/DB/config.test [deleted file]
helpers/basic_auth/DB/required.m4 [new file with mode: 0755]
helpers/basic_auth/LDAP/config.test [deleted file]
helpers/basic_auth/LDAP/required.m4 [new file with mode: 0755]
helpers/basic_auth/MSNT-multi-domain/config.test [deleted file]
helpers/basic_auth/MSNT-multi-domain/required.m4 [new file with mode: 0755]
helpers/basic_auth/MSNT/config.test [deleted file]
helpers/basic_auth/MSNT/required.m4 [new file with mode: 0755]
helpers/basic_auth/NCSA/config.test [deleted file]
helpers/basic_auth/NCSA/required.m4 [new file with mode: 0755]
helpers/basic_auth/NIS/config.test [deleted file]
helpers/basic_auth/NIS/required.m4 [new file with mode: 0755]
helpers/basic_auth/PAM/config.test [deleted file]
helpers/basic_auth/PAM/required.m4 [new file with mode: 0755]
helpers/basic_auth/POP3/config.test [deleted file]
helpers/basic_auth/POP3/required.m4 [new file with mode: 0755]
helpers/basic_auth/RADIUS/config.test [deleted file]
helpers/basic_auth/RADIUS/required.m4 [new file with mode: 0755]
helpers/basic_auth/SASL/config.test [deleted file]
helpers/basic_auth/SASL/required.m4 [new file with mode: 0755]
helpers/basic_auth/SMB/config.test [deleted file]
helpers/basic_auth/SMB/required.m4 [new file with mode: 0755]
helpers/basic_auth/SSPI/config.test [deleted file]
helpers/basic_auth/SSPI/required.m4 [new file with mode: 0755]
helpers/basic_auth/fake/config.test [deleted file]
helpers/basic_auth/fake/required.m4 [new file with mode: 0755]
helpers/basic_auth/getpwnam/config.test [deleted file]
helpers/basic_auth/getpwnam/required.m4 [new file with mode: 0755]
helpers/basic_auth/modules.m4 [new file with mode: 0644]

index cc7569724a94dd2d8bd795d4d0ad3d7c25826e9e..0c0b2292f125315a089abaeeac53de58cc6eed94 100644 (file)
@@ -249,3 +249,30 @@ AS_IF([test "$ac_res" != no],
       [$4])
 AS_VAR_POPDEF([ac_Search])dnl
 ])
+
+dnl Check for Cyrus SASL
+AC_DEFUN([SQUID_CHECK_SASL],[
+  squid_sasl_present="auto"
+  AC_CHECK_HEADERS(sasl/sasl.h sasl.h)
+  AC_CHECK_LIB(sasl2,sasl_errstring,[LIBSASL="-lsasl2"],[
+    AC_CHECK_LIB(sasl,sasl_errstring,[LIBSASL="-lsasl"], [
+      squid_sasl_present="no"
+    ])
+  ])
+  case "$squid_host_os" in
+    Darwin)
+      if test "$ac_cv_lib_sasl2_sasl_errstring" = "yes" ; then
+        AC_DEFINE(HAVE_SASL_DARWIN,1,[Define to 1 if Mac Darwin without sasl.h])
+        echo "checking for MAC Darwin without sasl.h ... yes"
+        squid_sasl_present="yes"
+      else
+        echo "checking for MAC Darwin without sasl.h ... no"
+        squid_sasl_present="no"
+      fi
+      ;;
+  esac
+  if test "x$squid_sasl_present" != "yes"; then
+    AC_MSG_WARN(Neither SASL nor SASL2 found)
+  fi
+  AC_SUBST(LIBSASL)
+])
index 7e90292049dc7a39c4313dae9e75f82238bc644f..87fc3ed46822ed94c6399fa0d95e7f87ad372ca9 100644 (file)
@@ -1726,45 +1726,7 @@ AC_ARG_ENABLE(auth-basic,
       To see available helpers, see the helpers/basic_auth directory. ]),[
 #nothing to do really
 ])
-#not specified. Inherit global
-if test "x$enable_auth_basic" = "x"; then
-    enable_auth_basic=$enable_auth
-fi
-#conflicts with global
-if test "x$enable_auth_basic" != "xno" -a "x$enable_auth" = "xno" ; then
-    AC_MSG_ERROR([Basic auth requested but auth disabled])
-fi
-#define list of modules to build
-if test "x$enable_auth_basic" = "xyes" ; then
-    SQUID_LOOK_FOR_MODULES([$srcdir/helpers/basic_auth],[enable_auth_basic])
-fi
-#handle the "none" special case
-if test "x$enable_auth_basic" = "xnone" ; then
-    enable_auth_basic=""
-fi
-BASIC_AUTH_HELPERS=""
-#enable_auth_basic contains either "no" or the list of modules to be built
-enable_auth_basic="`echo $enable_auth_basic| sed -e 's/,/ /g;s/  */ /g'`"
-if test "x$enable_auth_basic" != "xno" ; then
-    AUTH_MODULES="$AUTH_MODULES basic"
-    AC_DEFINE([HAVE_AUTH_MODULE_BASIC],1,[Basic auth module is built])
-    for helper in $enable_auth_basic
-    do
-    dir="$srcdir/helpers/basic_auth/$helper"
-    if test -f "$dir/config.test" && sh "$dir/config.test" "$squid_host_os"; then
-      BASIC_AUTH_HELPERS="$BASIC_AUTH_HELPERS $helper"
-      # special case
-      if test "x$helper" = "xSASL" ; then
-        squid_require_sasl=yes
-      fi
-    elif test -d "$srcdir/helpers/basic_auth/$helper" ; then
-      AC_MSG_NOTICE([Basic auth helper $helper ... found but cannot be built])
-    fi
-    done
-fi
-AC_MSG_NOTICE([Basic auth helpers to be built: $BASIC_AUTH_HELPERS])
-AM_CONDITIONAL(ENABLE_AUTH_BASIC, test "x$enable_auth_basic" != "xno")
-AC_SUBST(BASIC_AUTH_HELPERS)
+m4_include([helpers/basic_auth/modules.m4])
 
 AC_ARG_ENABLE(auth-ntlm,
   AS_HELP_STRING([--enable-auth-ntlm="list of helpers"],
@@ -2096,7 +2058,7 @@ if test "x$enable_external_acl_helpers" != "xno" ; then
       EXTERNAL_ACL_HELPERS="$EXTERNAL_ACL_HELPERS $helper"
       # special case
       if test "x$helper" = "xkerberos_ldap_group" ; then
-        squid_require_sasl=yes
+        SQUID_CHECK_SASL
       fi
     else
       AC_MSG_NOTICE([external acl helper $helper ... found but cannot be built])
@@ -2184,27 +2146,6 @@ SQUID_DEFINE_BOOL(USE_WIN32_SERVICE,${enable_win32_service:=no},
 AC_MSG_NOTICE([MS Windows service mode enabled: $enable_win32_service])
 
 
-# Check for Cyrus SASL
-if test "x$squid_require_sasl" = "xyes"; then
-  AC_CHECK_HEADERS(sasl/sasl.h sasl.h)
-  AC_CHECK_LIB(sasl2,sasl_errstring,[LIBSASL="-lsasl2"],[
-    AC_CHECK_LIB(sasl,sasl_errstring,[LIBSASL="-lsasl"], [
-      AC_MSG_ERROR(Neither SASL nor SASL2 found)
-    ])
-  ])
-  case "$squid_host_os" in
-    Darwin)
-      if test "$ac_cv_lib_sasl2_sasl_errstring" = "yes" ; then
-        AC_DEFINE(HAVE_SASL_DARWIN,1,[Define to 1 if Mac Darwin without sasl.h])
-        echo "checking for MAC Darwin without sasl.h ... yes"
-      else
-        echo "checking for MAC Darwin without sasl.h ... no"
-      fi
-      ;;
-  esac
-  AC_SUBST(LIBSASL)
-fi
-
 # Disable "unlinkd" code
 AC_ARG_ENABLE(unlinkd,
   AS_HELP_STRING([--disable-unlinkd],[Do not use unlinkd]), [
diff --git a/helpers/basic_auth/DB/config.test b/helpers/basic_auth/DB/config.test
deleted file mode 100755 (executable)
index 387b7b1..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-## Test: do we have perl to build the helper scripts?
-## Test: do we have pod2man to build the manual?
-perl --version >/dev/null && echo | pod2man >/dev/null
-
-exit $?
diff --git a/helpers/basic_auth/DB/required.m4 b/helpers/basic_auth/DB/required.m4
new file mode 100755 (executable)
index 0000000..00f761f
--- /dev/null
@@ -0,0 +1,3 @@
+if test "x$PERL" != "x" -a "x$POD2MAN" != "x"; then
+  BUILD_HELPER="DB"
+fi
diff --git a/helpers/basic_auth/LDAP/config.test b/helpers/basic_auth/LDAP/config.test
deleted file mode 100755 (executable)
index 4326b7c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-if [ -f /usr/include/ldap.h -o -f /usr/local/include/ldap.h ]; then
-       exit 0
-fi
-if [ -f /usr/include/winldap.h ]; then
-       exit 0
-fi
-exit 1
diff --git a/helpers/basic_auth/LDAP/required.m4 b/helpers/basic_auth/LDAP/required.m4
new file mode 100755 (executable)
index 0000000..c534c12
--- /dev/null
@@ -0,0 +1 @@
+AC_CHECK_HEADERS([ldap.h winldap.h],[BUILD_HELPER="LDAP"])
diff --git a/helpers/basic_auth/MSNT-multi-domain/config.test b/helpers/basic_auth/MSNT-multi-domain/config.test
deleted file mode 100755 (executable)
index 039e4d0..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-exit 0
diff --git a/helpers/basic_auth/MSNT-multi-domain/required.m4 b/helpers/basic_auth/MSNT-multi-domain/required.m4
new file mode 100755 (executable)
index 0000000..28359a0
--- /dev/null
@@ -0,0 +1 @@
+BUILD_HELPER="MSNT-multi-domain"
diff --git a/helpers/basic_auth/MSNT/config.test b/helpers/basic_auth/MSNT/config.test
deleted file mode 100755 (executable)
index f75f12e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-#
-# Don't build this helper on Windows
-#
-if test "$1" = "mingw"; then
-        exit 1
-fi
-if [ -f /usr/include/w32api/windows.h ]; then
-       exit 1
-fi
-if [ -f /usr/include/windows.h ]; then
-       exit 1
-fi
-exit 0
diff --git a/helpers/basic_auth/MSNT/required.m4 b/helpers/basic_auth/MSNT/required.m4
new file mode 100755 (executable)
index 0000000..2dbd013
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# DONT build this helper on Windows
+#
+# XXX: do we really need the mingw check?
+if test "$squid_host_os" != "mingw"; then
+  BUILD_HELPER="MSNT"
+  AC_CHECK_HEADERS([w32api/windows.h windows.h],[BUILD_HELPER=""])
+fi
diff --git a/helpers/basic_auth/NCSA/config.test b/helpers/basic_auth/NCSA/config.test
deleted file mode 100755 (executable)
index 039e4d0..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-exit 0
diff --git a/helpers/basic_auth/NCSA/required.m4 b/helpers/basic_auth/NCSA/required.m4
new file mode 100755 (executable)
index 0000000..0eddea8
--- /dev/null
@@ -0,0 +1 @@
+BUILD_HELPER="NCSA"
diff --git a/helpers/basic_auth/NIS/config.test b/helpers/basic_auth/NIS/config.test
deleted file mode 100755 (executable)
index 3036e73..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-if [ -f /usr/include/rpcsvc/yp_prot.h ]; then
-       exit 0
-fi
-exit 1
diff --git a/helpers/basic_auth/NIS/required.m4 b/helpers/basic_auth/NIS/required.m4
new file mode 100755 (executable)
index 0000000..4b66a61
--- /dev/null
@@ -0,0 +1 @@
+AC_CHECK_HEADERS([rpcsvc/yp_prot.h],[BUILD_HELPER="NIS"])
diff --git a/helpers/basic_auth/PAM/config.test b/helpers/basic_auth/PAM/config.test
deleted file mode 100755 (executable)
index be2cb29..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-if [ -f /usr/include/security/pam_appl.h ]; then
-       exit 0
-fi
-exit 1
diff --git a/helpers/basic_auth/PAM/required.m4 b/helpers/basic_auth/PAM/required.m4
new file mode 100755 (executable)
index 0000000..b5a2078
--- /dev/null
@@ -0,0 +1 @@
+AC_CHECK_HEADERS([security/pam_appl.h],[BUILD_HELPER="PAM"])
diff --git a/helpers/basic_auth/POP3/config.test b/helpers/basic_auth/POP3/config.test
deleted file mode 100755 (executable)
index 039e4d0..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-exit 0
diff --git a/helpers/basic_auth/POP3/required.m4 b/helpers/basic_auth/POP3/required.m4
new file mode 100755 (executable)
index 0000000..42dee40
--- /dev/null
@@ -0,0 +1 @@
+BUILD_HELPER="POP3"
diff --git a/helpers/basic_auth/RADIUS/config.test b/helpers/basic_auth/RADIUS/config.test
deleted file mode 100755 (executable)
index 039e4d0..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-exit 0
diff --git a/helpers/basic_auth/RADIUS/required.m4 b/helpers/basic_auth/RADIUS/required.m4
new file mode 100755 (executable)
index 0000000..34152e5
--- /dev/null
@@ -0,0 +1 @@
+BUILD_HELPER="RADIUS"
diff --git a/helpers/basic_auth/SASL/config.test b/helpers/basic_auth/SASL/config.test
deleted file mode 100755 (executable)
index 871e278..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-if [ -f /usr/include/sasl.h -o -f /usr/local/include/sasl.h ]; then
-       exit 0
-fi
-if [ -f /usr/include/sasl/sasl.h -o -f /usr/local/include/sasl/sasl.h ]; then
-       exit 0
-fi
-exit 1
diff --git a/helpers/basic_auth/SASL/required.m4 b/helpers/basic_auth/SASL/required.m4
new file mode 100755 (executable)
index 0000000..e8ccaec
--- /dev/null
@@ -0,0 +1,6 @@
+SQUID_CHECK_SASL
+
+# on success, add to the built modules list
+if test "x$squid_check_sasl" = "xyes"; then
+  BUILD_HELPER="SASL"
+fi
diff --git a/helpers/basic_auth/SMB/config.test b/helpers/basic_auth/SMB/config.test
deleted file mode 100755 (executable)
index ece0560..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-for prefix in /usr/local /opt /opt/samba /usr/local/samba /usr
-do
-    if [ -x ${prefix}/bin/smbclient ]; then
-        exit 0
-    fi
-done
-echo "WARNING: Samba smbclient not found in default location. basic_smb_auth may not work on this machine"
-# allow script install anyway.
-exit 0
diff --git a/helpers/basic_auth/SMB/required.m4 b/helpers/basic_auth/SMB/required.m4
new file mode 100755 (executable)
index 0000000..0e7ae2c
--- /dev/null
@@ -0,0 +1,14 @@
+#
+## TODO: This can be done far better I'm sure
+#
+for prefix in /usr/local /opt /opt/samba /usr/local/samba /usr
+do
+    if [ -x ${prefix}/bin/smbclient ]; then
+        BUILD_HELPER="SMB"
+    fi
+done
+if test "x$BUILD_HELPER" = "x"; then
+  AC_MSG_WARN([Samba smbclient not found in default location. basic_smb_auth may not work on this machine])
+fi
+# allow script install anyway.
+BUILD_HELPER="SMB"
diff --git a/helpers/basic_auth/SSPI/config.test b/helpers/basic_auth/SSPI/config.test
deleted file mode 100755 (executable)
index eb7626b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-#
-# Only build this helper on Windows
-#
-if test "$1" = "mingw"; then
-       exit 0
-fi
-if [ -f /usr/include/w32api/windows.h ]; then
-       exit 0
-fi
-if [ -f /usr/include/windows.h ]; then
-       exit 0
-fi
-exit 1
diff --git a/helpers/basic_auth/SSPI/required.m4 b/helpers/basic_auth/SSPI/required.m4
new file mode 100755 (executable)
index 0000000..546ca2f
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# Only build this helper on Windows
+#
+# FIXME: do we really need the mingw check anymore?
+if test "$squid_host_os" = "mingw"; then
+       BUILD_HELPER="SSPI"
+fi
+AC_CHECK_HEADERS([w32api/windows.h windows.h],[BUILD_HELPER="SSPI"])
diff --git a/helpers/basic_auth/fake/config.test b/helpers/basic_auth/fake/config.test
deleted file mode 100755 (executable)
index 039e4d0..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-exit 0
diff --git a/helpers/basic_auth/fake/required.m4 b/helpers/basic_auth/fake/required.m4
new file mode 100755 (executable)
index 0000000..5261ae5
--- /dev/null
@@ -0,0 +1 @@
+BUILD_HELPER="fake"
diff --git a/helpers/basic_auth/getpwnam/config.test b/helpers/basic_auth/getpwnam/config.test
deleted file mode 100755 (executable)
index 8511220..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-if [ -f /usr/include/pwd.h ]; then
-       exit 0
-fi
-exit 1
diff --git a/helpers/basic_auth/getpwnam/required.m4 b/helpers/basic_auth/getpwnam/required.m4
new file mode 100755 (executable)
index 0000000..a976481
--- /dev/null
@@ -0,0 +1 @@
+AC_CHECK_HEADERS([pwd.h],[BUILD_HELPER="getpwnam"])
diff --git a/helpers/basic_auth/modules.m4 b/helpers/basic_auth/modules.m4
new file mode 100644 (file)
index 0000000..8fc63ad
--- /dev/null
@@ -0,0 +1,93 @@
+# This file is supposed to run all the tests required to identify which
+# configured modules are able to be built in this environment
+
+# FIXME: de-duplicate $enable_auth_basic list containing double entries.
+
+#not specified. Inherit global
+if test "x$enable_auth_basic" = "x"; then
+    enable_auth_basic=$enable_auth
+fi
+#conflicts with global
+if test "x$enable_auth_basic" != "xno" -a "x$enable_auth" = "xno" ; then
+    AC_MSG_ERROR([Basic auth requested but auth disabled])
+fi
+#define list of modules to build
+if test "x$enable_auth_basic" = "xyes" ; then
+    SQUID_LOOK_FOR_MODULES([$srcdir/helpers/basic_auth],[enable_auth_basic])
+fi
+#handle the "none" special case
+if test "x$enable_auth_basic" = "xnone" ; then
+    enable_auth_basic=""
+fi
+
+BASIC_AUTH_HELPERS=""
+#enable_auth_basic contains either "no" or the list of modules to be built
+enable_auth_basic="`echo $enable_auth_basic| sed -e 's/,/ /g;s/  */ /g'`"
+if test "x$enable_auth_basic" != "xno" ; then
+    AUTH_MODULES="$AUTH_MODULES basic"
+    AC_DEFINE([HAVE_AUTH_MODULE_BASIC],1,[Basic auth module is built])
+    for helper in $enable_auth_basic
+    do
+    dir="$srcdir/helpers/basic_auth/$helper"
+
+      # modules converted to autoconf macros already
+      # NP: we only need this list because m4_include() does not accept variables
+      if test "x$helper" = "xDB" ; then
+        m4_include([helpers/basic_auth/DB/required.m4])
+
+      elif test "x$helper" = "xLDAP" ; then
+        m4_include([helpers/basic_auth/LDAP/required.m4])
+
+      elif test "x$helper" = "xMSNT-multi-domain" ; then
+        m4_include([helpers/basic_auth/MSNT-multi-domain/required.m4])
+
+      elif test "x$helper" = "xMSNT" ; then
+        m4_include([helpers/basic_auth/MSNT/required.m4])
+
+      elif test "x$helper" = "xNCSA" ; then
+        m4_include([helpers/basic_auth/NCSA/required.m4])
+
+      elif test "x$helper" = "xNIS" ; then
+        m4_include([helpers/basic_auth/NIS/required.m4])
+
+      elif test "x$helper" = "xPOP3" ; then
+        m4_include([helpers/basic_auth/POP3/required.m4])
+
+      elif test "x$helper" = "xRADIUS" ; then
+        m4_include([helpers/basic_auth/RADIUS/required.m4])
+
+      elif test "x$helper" = "xSASL" ; then
+        m4_include([helpers/basic_auth/SASL/required.m4])
+
+      elif test "x$helper" = "xSMB" ; then
+        m4_include([helpers/basic_auth/SMB/required.m4])
+
+      elif test "x$helper" = "xSSPI" ; then
+        m4_include([helpers/basic_auth/SSPI/required.m4])
+
+      elif test "x$helper" = "xfake" ; then
+        m4_include([helpers/basic_auth/fake/required.m4])
+
+      elif test "x$helper" = "xgetpwnam" ; then
+        m4_include([helpers/basic_auth/getpwnam/required.m4])
+
+      # modules not yet converted to autoconf macros (or third party drop-in's)
+      elif test -f "$dir/config.test" && sh "$dir/config.test" "$squid_host_os"; then
+        BUILD_HELPER="$helper"
+      fi
+
+      if test -d "$srcdir/helpers/basic_auth/$helper"; then
+        if test "$BUILD_HELPER" != "$helper"; then
+          AC_MSG_NOTICE([Basic auth helper $helper ... found but cannot be built])
+        else
+          BASIC_AUTH_HELPERS="$BASIC_AUTH_HELPERS $BUILD_HELPER"
+        fi
+      else
+          AC_MSG_ERROR([Basic auth helper $helper ... not found])
+      fi
+    done
+fi
+
+AC_MSG_NOTICE([Basic auth helpers to be built: $BASIC_AUTH_HELPERS])
+AM_CONDITIONAL(ENABLE_AUTH_BASIC, test "x$enable_auth_basic" != "xno")
+AC_SUBST(BASIC_AUTH_HELPERS)