From 90c2083a3cd3cbe1b87655bf5b9727e2d5110dca Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Tue, 11 Jan 2011 00:33:27 -0700 Subject: [PATCH] Bug 2959: remove SAMBAPREFIX dependency This removes the tricky SAMBAPREFIX variable which passes full-path information from the squid build machine down to the run-time host helper. Such information is not always correct when crossing machines, and the binaries being run can easily be added to PATH in the run-time host environment instead. The net result of doing this is removal of Samba from the build dependencies and increased availability of the basic_smb_auth and ext_wbinfo_group_acl helpers. --- helpers/basic_auth/SMB/Makefile.am | 16 ++------------ helpers/basic_auth/SMB/basic_smb_auth.cc | 4 ---- helpers/basic_auth/SMB/basic_smb_auth.sh | 6 ++--- helpers/basic_auth/SMB/config.test | 6 +++-- helpers/external_acl/wbinfo_group/config.test | 22 ++++++++++++------- 5 files changed, 23 insertions(+), 31 deletions(-) diff --git a/helpers/basic_auth/SMB/Makefile.am b/helpers/basic_auth/SMB/Makefile.am index 0d52e7b3de..561c3bca55 100644 --- a/helpers/basic_auth/SMB/Makefile.am +++ b/helpers/basic_auth/SMB/Makefile.am @@ -1,21 +1,9 @@ include $(top_srcdir)/src/Common.am -# SAMBAPREFIX must point to the directory where Samba has been installed. -# By default, Samba is installed in /usr/local/samba. If you changed this -# by using the --prefix option when configuring Samba, you need to change -# SAMBAPREFIX accordingly. - -## FIXME: autoconf should test for the samba path. - -SMB_AUTH_HELPER = basic_smb_auth.sh -SAMBAPREFIX=/usr/local/samba -SMB_AUTH_HELPER_PATH = $(libexecdir)/$(SMB_AUTH_HELPER) - -libexec_SCRIPTS = $(SMB_AUTH_HELPER) - +libexec_SCRIPTS = basic_smb_auth.sh libexec_PROGRAMS = basic_smb_auth basic_smb_auth_SOURCES= basic_smb_auth.cc -basic_smb_auth_CXXFLAGS = -DSAMBAPREFIX=\"$(SAMBAPREFIX)\" -DHELPERSCRIPT=\"$(SMB_AUTH_HELPER_PATH)\" +basic_smb_auth_CXXFLAGS = -DHELPERSCRIPT=\"$(libexecdir)/basic_smb_auth.sh\" basic_smb_auth_LDADD = \ $(top_builddir)/lib/libmiscencoding.la \ $(COMPAT_LIB) \ diff --git a/helpers/basic_auth/SMB/basic_smb_auth.cc b/helpers/basic_auth/SMB/basic_smb_auth.cc index 1f84f7f386..bdaf3ca486 100644 --- a/helpers/basic_auth/SMB/basic_smb_auth.cc +++ b/helpers/basic_auth/SMB/basic_smb_auth.cc @@ -197,10 +197,6 @@ main(int argc, char *argv[]) shcmd = debug_enabled ? HELPERSCRIPT : HELPERSCRIPT " > /dev/null 2>&1"; - /* pass to helper script */ - if (putenv((char *)"SAMBAPREFIX=" SAMBAPREFIX) != 0) - return 1; - while (fgets(buf, HELPER_INPUT_BUFFER, stdin) != NULL) { if ((s = strchr(buf, '\n')) == NULL) diff --git a/helpers/basic_auth/SMB/basic_smb_auth.sh b/helpers/basic_auth/SMB/basic_smb_auth.sh index 99f86150b3..2a1abb3b6e 100755 --- a/helpers/basic_auth/SMB/basic_smb_auth.sh +++ b/helpers/basic_auth/SMB/basic_smb_auth.sh @@ -47,13 +47,13 @@ else addropt="" fi echo "Query address options: $addropt" -dcip=`$SAMBAPREFIX/bin/nmblookup $addropt "$PASSTHROUGH#1c" | awk '/^[0-9.]+ / { print $1 ; exit }'` +dcip=`nmblookup $addropt "$PASSTHROUGH#1c" | awk '/^[0-9.]+ / { print $1 ; exit }'` echo "Domain controller IP address: $dcip" [ -n "$dcip" ] || exit 1 # All right, we have the IP address of a domain controller, # but we need its name too -dcname=`$SAMBAPREFIX/bin/nmblookup -A $dcip | awk '$2 == "<00>" { print $1 ; exit }'` +dcname=`nmblookup -A $dcip | awk '$2 == "<00>" { print $1 ; exit }'` echo "Domain controller NETBIOS name: $dcname" [ -n "$dcname" ] || exit 1 @@ -63,7 +63,7 @@ export USER # Read the contents of the file $AUTHFILE on the $AUTHSHARE share authfilebs=`echo "$AUTHFILE" | tr / '\\\\'` -authinfo=`$SAMBAPREFIX/bin/smbclient "//$dcname/$AUTHSHARE" -I $dcip -d 0 -E -W "$DOMAINNAME" -c "get $authfilebs -" 2>/dev/null` +authinfo=`smbclient "//$dcname/$AUTHSHARE" -I $dcip -d 0 -E -W "$DOMAINNAME" -c "get $authfilebs -" 2>/dev/null` echo "Contents of //$dcname/$AUTHSHARE/$AUTHFILE: $authinfo" # Allow for both \n and \r\n end-of-line termination diff --git a/helpers/basic_auth/SMB/config.test b/helpers/basic_auth/SMB/config.test index f41b21fd12..ece056001d 100755 --- a/helpers/basic_auth/SMB/config.test +++ b/helpers/basic_auth/SMB/config.test @@ -1,8 +1,10 @@ #!/bin/sh -for prefix in ${SAMBAPREFIX} /usr/local /opt /opt/samba /usr/local/samba /usr +for prefix in /usr/local /opt /opt/samba /usr/local/samba /usr do if [ -x ${prefix}/bin/smbclient ]; then exit 0 fi done -exit 1 +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/external_acl/wbinfo_group/config.test b/helpers/external_acl/wbinfo_group/config.test index fdaf038639..ea9995da34 100755 --- a/helpers/external_acl/wbinfo_group/config.test +++ b/helpers/external_acl/wbinfo_group/config.test @@ -1,12 +1,18 @@ #!/bin/sh - -for sambaprefix in ${SAMBAPREFIX} /usr/local /opt /opt/samba /usr/local/samba /usr +samba_found="no" +for sambaprefix in /usr/local /opt /opt/samba /usr/local/samba /usr do - for perlprefix in /usr /usr/local /opt /opt/perl - do - if [ -x $sambaprefix/bin/wbinfo -a -x $perlprefix/bin/perl ]; then - exit 0 - fi - done + if [ -x $sambaprefix/bin/wbinfo ]; then + samba_found="yes" + fi +done +if test "$samba_found" = "no"; then + echo "WARNING: Samba wbinfo not found in default location. ext_wbinfo_group_acl may not work on this machine" +fi +for perlprefix in /usr /usr/local /opt /opt/perl +do + if [ -x $perlprefix/bin/perl ]; then + exit 0 + fi done exit 1 -- 2.47.2