[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Tue Feb 14 08:44:01 UTC 2023


The branch, master has been updated
       via  238056e5aad ctdb-scripts: Avoid using testparm to process its own output
       via  9a04ca1e1cd ctdb-scripts: Do not replace commas with spaces in "smb ports" list
       via  029dddfb79f ctdb-scripts: Reformat script with "shfmt -w -p -i 0 -fn"
      from  5d8647376fb vfs: Fix whitespace in vfs_aixacl_util.c

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 238056e5aadb597e3f6165757990a88952644866
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Mon Feb 13 14:59:18 2023 +1100

    ctdb-scripts: Avoid using testparm to process its own output
    
    When testparm processes the output of "testparm -v" (which includes
    default values) it appears to do global checks (or some other sort of
    initialisation logic) for all specified values.  This includes a DNS
    lookup for the node's hostname, as a side-effect of a libldap
    ldap_set_option() call when processing "ldap debug level".  If DNS
    servers are down then this can induce timeouts, possibly resulting in
    monitor timeouts.
    
    Avoid this by using sed to extract configuration values from the
    testparm cache file.
    
    This is already shown to work when retrieving share paths, where
    testparm is basically used as cat.  Update the sed pattern to avoid
    matching empty values on the right-hand side of the equals ('=') -
    this avoids the default empty path value (and "smb ports" never has an
    empty value).
    
    Corresponding test changes:
    
    * 50.samba.monitor.111.sh no longer expects a failure from being
      unable to set smb ports, since testparm is no longer used in that
      code path.
    
    * smb ports needs to be set in fake smb.conf so it is in the default
      output and can be extracted using sed.
    
    * Although testparm --parameter-name is no longer used in
      50.samba.script, update the stub implementation (in case it is ever
      used again) to extract from fake smb.conf, since "smb ports" is now
      set there.  The change from $parameter to $param allows a long line
      to stay below 80 columns.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Tue Feb 14 08:43:53 UTC 2023 on atb-devel-224

commit 9a04ca1e1cdf90065338b0ecb27043e63109a2cb
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Tue Feb 14 12:36:11 2023 +1100

    ctdb-scripts: Do not replace commas with spaces in "smb ports" list
    
    The list changed back to space-separated in commit
    93448f4be92d4e018aaf2f9705f0351360b2ed0f, so simplify the code a
    little.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 029dddfb79fb557039c9daa9eebde333e6d19233
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Mon Feb 13 13:02:52 2023 +1100

    ctdb-scripts: Reformat script with "shfmt -w -p -i 0 -fn"
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/config/events/legacy/50.samba.script          | 167 +++++++++++----------
 .../UNIT/eventscripts/50.samba.monitor.111.sh      |   4 +-
 ctdb/tests/UNIT/eventscripts/etc/samba/smb.conf    |   1 +
 ctdb/tests/UNIT/eventscripts/stubs/testparm        |  23 +--
 4 files changed, 95 insertions(+), 100 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/config/events/legacy/50.samba.script b/ctdb/config/events/legacy/50.samba.script
index 81c6e7fa6ba..84600e25024 100755
--- a/ctdb/config/events/legacy/50.samba.script
+++ b/ctdb/config/events/legacy/50.samba.script
@@ -1,7 +1,7 @@
 #!/bin/sh
 # ctdb event script for Samba
 
-[ -n "$CTDB_BASE" ] || \
+[ -n "$CTDB_BASE" ] ||
 	CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
@@ -9,16 +9,16 @@
 detect_init_style
 
 case $CTDB_INIT_STYLE in
-	suse)
-		CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb}
-		;;
-	debian)
-		CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smbd}
-		;;
-	*)
-		# Use redhat style as default:
-		CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb}
-		;;
+suse)
+	CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb}
+	;;
+debian)
+	CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smbd}
+	;;
+*)
+	# Use redhat style as default:
+	CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb}
+	;;
 esac
 
 service_name="samba"
@@ -27,25 +27,25 @@ load_script_options
 
 ctdb_setup_state_dir "service" "$service_name"
 
-service_start ()
+service_start()
 {
-    # make sure samba is not already started
-    service "$CTDB_SERVICE_SMB" stop > /dev/null 2>&1
-    killall -0 -q smbd && {
-	sleep 1
-	# make absolutely sure samba is dead
-	killall -q -9 smbd
-    }
-    # start Samba service. Start it reniced, as under very heavy load
-    # the number of smbd processes will mean that it leaves few cycles
-    # for anything else
-    nice_service "$CTDB_SERVICE_SMB" start || die "Failed to start samba"
+	# make sure samba is not already started
+	service "$CTDB_SERVICE_SMB" stop >/dev/null 2>&1
+	killall -0 -q smbd && {
+		sleep 1
+		# make absolutely sure samba is dead
+		killall -q -9 smbd
+	}
+	# start Samba service. Start it reniced, as under very heavy load
+	# the number of smbd processes will mean that it leaves few cycles
+	# for anything else
+	nice_service "$CTDB_SERVICE_SMB" start || die "Failed to start samba"
 }
 
-service_stop ()
+service_stop()
 {
-    service "$CTDB_SERVICE_SMB" stop
-    program_stack_traces "smbd" 5
+	service "$CTDB_SERVICE_SMB" stop
+	program_stack_traces "smbd" 5
 }
 
 ######################################################################
@@ -56,74 +56,77 @@ service_stop ()
 # shellcheck disable=SC2154
 smbconf_cache="$script_state_dir/smb.conf.cache"
 
-testparm_foreground_update ()
+testparm_foreground_update()
 {
-    _timeout="$1"
+	_timeout="$1"
 
-    # No need to remove these temporary files, since there are only 2
-    # of them.
-    _out="${smbconf_cache}.out"
-    _err="${smbconf_cache}.err"
+	# No need to remove these temporary files, since there are only 2
+	# of them.
+	_out="${smbconf_cache}.out"
+	_err="${smbconf_cache}.err"
 
-    timeout "$_timeout" testparm -v -s >"$_out" 2>"$_err"
-    case $? in
+	timeout "$_timeout" testparm -v -s >"$_out" 2>"$_err"
+	case $? in
 	0) : ;;
 	124)
-	    if [ -f "$smbconf_cache" ] ; then
-		echo "WARNING: smb.conf cache update timed out - using old cache file"
-		return 1
-	    else
-		echo "ERROR: smb.conf cache create failed - testparm command timed out"
-		exit 1
-	    fi
-	    ;;
+		if [ -f "$smbconf_cache" ]; then
+			echo "WARNING: smb.conf cache update timed out - using old cache file"
+			return 1
+		else
+			echo "ERROR: smb.conf cache create failed - testparm command timed out"
+			exit 1
+		fi
+		;;
 	*)
-	    if [ -f "$smbconf_cache" ] ; then
-		echo "WARNING: smb.conf cache update failed - using old cache file"
-		cat "$_err"
-		return 1
-	    else
-		echo "ERROR: smb.conf cache create failed - testparm failed with:"
-		cat "$_err"
-		exit 1
-	    fi
-    esac
-
-    # Only using $$ here to avoid a collision.  This is written into
-    # CTDB's own state directory so there is no real need for a secure
-    # temporary file.
-    _tmpfile="${smbconf_cache}.$$"
-    # Patterns to exclude...
-    _pat='^[[:space:]]+(registry[[:space:]]+shares|include|copy|winbind[[:space:]]+separator)[[:space:]]+='
-    grep -Ev "$_pat" <"$_out" >"$_tmpfile"
-    mv "$_tmpfile" "$smbconf_cache" # atomic
-
-    return 0
+		if [ -f "$smbconf_cache" ]; then
+			echo "WARNING: smb.conf cache update failed - using old cache file"
+			cat "$_err"
+			return 1
+		else
+			echo "ERROR: smb.conf cache create failed - testparm failed with:"
+			cat "$_err"
+			exit 1
+		fi
+		;;
+	esac
+
+	# Only using $$ here to avoid a collision.  This is written into
+	# CTDB's own state directory so there is no real need for a secure
+	# temporary file.
+	_tmpfile="${smbconf_cache}.$$"
+	# Patterns to exclude...
+	_pat='^[[:space:]]+(registry[[:space:]]+shares|include|copy|winbind[[:space:]]+separator)[[:space:]]+='
+	grep -Ev "$_pat" <"$_out" >"$_tmpfile"
+	mv "$_tmpfile" "$smbconf_cache" # atomic
+
+	return 0
 }
 
-testparm_background_update ()
+testparm_background_update()
 {
-    _timeout="$1"
+	_timeout="$1"
 
-    testparm_foreground_update "$_timeout" >/dev/null 2>&1 </dev/null &
+	testparm_foreground_update "$_timeout" >/dev/null 2>&1 </dev/null &
 }
 
-testparm_cat ()
+testparm_get ()
 {
-    testparm -s "$smbconf_cache" "$@" 2>/dev/null
+	_param="$1"
+
+	sed -n \
+	    -e "s|^[[:space:]]*${_param}[[:space:]]*=[[:space:]]\(..*\)|\1|p" \
+	    "$smbconf_cache"
+
 }
 
-list_samba_shares ()
+list_samba_shares()
 {
-    testparm_cat |
-    sed -n -e 's@^[[:space:]]*path[[:space:]]*=[[:space:]]@@p' |
-    sed -e 's/"//g'
+	testparm_get "path" | sed -e 's/"//g'
 }
 
-list_samba_ports ()
+list_samba_ports()
 {
-    testparm_cat --parameter-name="smb ports" |
-    sed -e 's@,@ @g'
+	testparm_get "smb ports"
 }
 
 ###########################
@@ -142,20 +145,20 @@ monitor)
 	ret=$?
 
 	smb_ports="$CTDB_SAMBA_CHECK_PORTS"
-	if [ -z "$smb_ports" ] ; then
-	    smb_ports=$(list_samba_ports)
-	    [ -n "$smb_ports" ] || die "Failed to set smb ports"
+	if [ -z "$smb_ports" ]; then
+		smb_ports=$(list_samba_ports)
+		[ -n "$smb_ports" ] || die "Failed to set smb ports"
 	fi
 	# Intentionally unquoted multi-word value here
 	# shellcheck disable=SC2086
 	ctdb_check_tcp_ports $smb_ports || exit $?
 
-	if [ "$CTDB_SAMBA_SKIP_SHARE_CHECK" != "yes" ] ; then
-	    list_samba_shares | ctdb_check_directories || exit $?
+	if [ "$CTDB_SAMBA_SKIP_SHARE_CHECK" != "yes" ]; then
+		list_samba_shares | ctdb_check_directories || exit $?
 	fi
 
-	if [ $ret -ne 0 ] ; then
-	    testparm_background_update 10
+	if [ $ret -ne 0 ]; then
+		testparm_background_update 10
 	fi
 	;;
 esac
diff --git a/ctdb/tests/UNIT/eventscripts/50.samba.monitor.111.sh b/ctdb/tests/UNIT/eventscripts/50.samba.monitor.111.sh
index 55df6da807e..d72855f2291 100755
--- a/ctdb/tests/UNIT/eventscripts/50.samba.monitor.111.sh
+++ b/ctdb/tests/UNIT/eventscripts/50.samba.monitor.111.sh
@@ -10,7 +10,7 @@ ok_null
 simple_test
 
 export FAKE_TESTPARM_FAIL="yes"
-required_result 1 <<EOF
+ok <<EOF
 WARNING: smb.conf cache update failed - using old cache file
 Load smb config files from ${CTDB_SYS_ETCDIR}/samba/smb.conf
 rlimit_max: increasing rlimit_max (2048) to minimum Windows limit (16384)
@@ -19,7 +19,5 @@ Processing section "[share2]"
 Processing section "[share3]"
 Loaded services file OK.
 WARNING: 'workgroup' and 'netbios name' must differ.
-
-Failed to set smb ports
 EOF
 simple_test
diff --git a/ctdb/tests/UNIT/eventscripts/etc/samba/smb.conf b/ctdb/tests/UNIT/eventscripts/etc/samba/smb.conf
index da89db2b81f..45976cd655a 100644
--- a/ctdb/tests/UNIT/eventscripts/etc/samba/smb.conf
+++ b/ctdb/tests/UNIT/eventscripts/etc/samba/smb.conf
@@ -40,3 +40,4 @@
 	map readonly = no
 	ea support = yes
 	dmapi support = no
+	smb ports = 445 139
diff --git a/ctdb/tests/UNIT/eventscripts/stubs/testparm b/ctdb/tests/UNIT/eventscripts/stubs/testparm
index 480326e63ff..faa0f347885 100755
--- a/ctdb/tests/UNIT/eventscripts/stubs/testparm
+++ b/ctdb/tests/UNIT/eventscripts/stubs/testparm
@@ -44,29 +44,22 @@ fi
 # the global one, unless some other file is specified.
 
 file=""
-parameter=""
+param=""
 for i; do
 	case "$i" in
-	--parameter-name=*) parameter="${i#--parameter-name=}" ;;
+	--parameter-name=*) param="${i#--parameter-name=}" ;;
 	-*) : ;;
 	*) file="$i" ;;
 	esac
 done
 
-# Just hard-code parameter requests for now.  Later on they could be
-# parsed out of the file.
-case "$parameter" in
-security)
-	echo "ADS"
+# Parse out parameter request
+if [ -n "$param" ]; then
+	sed -n \
+	    -e "s|^[[:space:]]*${param}[[:space:]]*=[[:space:]]\(..*\)|\1|p" \
+	    "${file:-"${CTDB_SYS_ETCDIR}/samba/smb.conf"}"
 	exit 0
-	;;
-smb*ports)
-	echo "445, 139"
-	exit 0
-	;;
-?*) not_implemented "--parameter-name=$parameter" ;;
-	# Fall through if $parameter not set
-esac
+fi
 
 if [ -n "$file" ]; then
 	# This should include the shares, since this is used when the


-- 
Samba Shared Repository



More information about the samba-cvs mailing list