[SCM] Samba Shared Repository - branch master updated

Martin Schwenke martins at samba.org
Mon Jan 16 14:47:02 UTC 2017


The branch, master has been updated
       via  ff0d45c ctdb-tests: Fix name of the variable representing init script
       via  ec3415e ctdb-scripts: Drop configuration variable CTDB_SCRIPT_DEBUGLEVEL
       via  a987053 ctdb-scripts: Drop function ctdb_check_command()
       via  c8249df ctdb-scripts: Inline simple uses of service_start() and service_stop()
       via  e847ec3 ctdb-scripts: Remove ctdb_service_start() and ctdb_service_stop()
       via  a9e3b63 ctdb-scripts: Drop unnecessary function ctdb_check_tcp_init()
       via  26b7841 ctdb-scripts: Simplify TCP port checking
       via  e70e773 ctdb-scripts: Drop configuration variable CTDB_SERVICE_AUTOSTARTSTOP
      from  e1874bb winbind: Fix CID 1398534 Dereference before null check

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


- Log -----------------------------------------------------------------
commit ff0d45c403d45e13bc07013a5ff47314f83dd647
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Jan 16 20:54:59 2017 +1100

    ctdb-tests: Fix name of the variable representing init script
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Mon Jan 16 15:46:42 CET 2017 on sn-devel-144

commit ec3415e5830399d145422ceb35a44531d27ace98
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jan 9 15:26:22 2017 +1100

    ctdb-scripts: Drop configuration variable CTDB_SCRIPT_DEBUGLEVEL
    
    The debug() function, which is the only user of this variable, is no
    longer used.  It is also dropped.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit a9870538c9876072bcd4b5f9b907a256d8737249
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jan 9 15:19:26 2017 +1100

    ctdb-scripts: Drop function ctdb_check_command()
    
    This is only used in 1 place, so just inline the check.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit c8249dfa0e72ece7d816ecf822a78843deabfeaa
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Dec 18 07:59:03 2016 +1100

    ctdb-scripts: Inline simple uses of service_start() and service_stop()
    
    This makes the scripts more readable.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit e847ec3ae24cc6c8c69284c7fe0791a319cf7142
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Dec 18 07:26:02 2016 +1100

    ctdb-scripts: Remove ctdb_service_start() and ctdb_service_stop()
    
    They contain too much unnecessary complexity, some of which was used
    to support CTDB_SERVICE_AUTOSTARTSTOP.
    
    Also removed unused functions for service management.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit a9e3b6353892b7ffbe37740d8677274dfb70d62b
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Dec 17 22:48:57 2016 +1100

    ctdb-scripts: Drop unnecessary function ctdb_check_tcp_init()
    
    The flag this sets is no longer used by ctdb_check_tcp_ports()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 26b7841aa6e51dfd5330695f21acab620f7dbed4
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Dec 17 22:40:05 2016 +1100

    ctdb-scripts: Simplify TCP port checking
    
    Commit 86792724a2a911da9cd3e75622d35084c88eb8ce added complications on
    top of the multiple TCP port checking methods that used to exist.
    Life is simpler now and the cause of any failures is obvious.  So just
    print a simple message if the port check fails.
    
    Tweak tests to match changes.  Drop one test that becomes a duplicate.
    
    Temporarily tweak ctdb_check_command() so that it passes shellcheck
    tests.  It will be removed anyway in a subsequent commit.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit e70e77383ca0e1ea9ccbe3f7698f0c6e3ba3c889
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Dec 18 06:21:27 2016 +1100

    ctdb-scripts: Drop configuration variable CTDB_SERVICE_AUTOSTARTSTOP
    
    This has bit-rotted, at least for NFS.  It can be fixed but it is
    better to remove it because it adds a lot of unnecessary complexity.
    
    Variable event_name becomes unused so remove it.  Also remove
    associated tests.
    
    To continue to manage/unmanage services while CTDB is running:
    
    * Start service by hand and then flag it as managed
    
    * Mark service as unmanaged and shut it down by hand
    
    In some cases CTDB does something fancy - e.g. start Samba under
    "nice", so care is needed.  One technique is to disable the
    eventscript, mark as managed, run the startup event by hand and then
    re-enable the eventscript.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

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

Summary of changes:
 ctdb/config/events.d/06.nfs                       |   2 -
 ctdb/config/events.d/31.clamd                     |  17 +-
 ctdb/config/events.d/40.vsftpd                    |  18 +-
 ctdb/config/events.d/41.httpd                     |   7 +-
 ctdb/config/events.d/49.winbind                   |  12 +-
 ctdb/config/events.d/50.samba                     |   6 +-
 ctdb/config/events.d/60.nfs                       |   2 -
 ctdb/config/events.d/70.iscsi                     |   2 -
 ctdb/config/functions                             | 215 +++-------------------
 ctdb/doc/ctdbd.conf.5.xml                         |  27 ---
 ctdb/tests/eventscripts/40.vsftpd.monitor.002.sh  |   4 +-
 ctdb/tests/eventscripts/49.winbind.monitor.050.sh |  16 --
 ctdb/tests/eventscripts/49.winbind.monitor.051.sh |  17 --
 ctdb/tests/eventscripts/50.samba.monitor.050.sh   |  16 --
 ctdb/tests/eventscripts/50.samba.monitor.051.sh   |  17 --
 ctdb/tests/eventscripts/50.samba.monitor.103.sh   |   2 +-
 ctdb/tests/eventscripts/50.samba.monitor.104.sh   |   2 +-
 ctdb/tests/eventscripts/50.samba.monitor.107.sh   |  17 --
 ctdb/tests/scripts/script_install_paths.sh        |   2 +-
 ctdb/tests/shellcheck/init_script.sh              |   2 +-
 20 files changed, 56 insertions(+), 347 deletions(-)
 delete mode 100755 ctdb/tests/eventscripts/49.winbind.monitor.050.sh
 delete mode 100755 ctdb/tests/eventscripts/49.winbind.monitor.051.sh
 delete mode 100755 ctdb/tests/eventscripts/50.samba.monitor.050.sh
 delete mode 100755 ctdb/tests/eventscripts/50.samba.monitor.051.sh
 delete mode 100755 ctdb/tests/eventscripts/50.samba.monitor.107.sh


Changeset truncated at 500 lines:

diff --git a/ctdb/config/events.d/06.nfs b/ctdb/config/events.d/06.nfs
index 0ecbb57..e59f265 100755
--- a/ctdb/config/events.d/06.nfs
+++ b/ctdb/config/events.d/06.nfs
@@ -27,8 +27,6 @@ nfs_callout_pre ()
 
 nfs_callout_init "$service_state_dir"
 
-ctdb_start_stop_service
-
 is_ctdb_managed_service || exit 0
 
 case "$1" in
diff --git a/ctdb/config/events.d/31.clamd b/ctdb/config/events.d/31.clamd
index 2d301eb..1b76365 100755
--- a/ctdb/config/events.d/31.clamd
+++ b/ctdb/config/events.d/31.clamd
@@ -23,26 +23,19 @@ redhat)
 	;;
 esac
 
-service_start ()
-{
-    service $service_name stop > /dev/null 2>&1
-    service $service_name start
-}
-
 loadconfig
 
-ctdb_start_stop_service
-
 is_ctdb_managed_service || exit 0
 
 case "$1" in
 startup)
-	ctdb_service_start
-        ;;
+	service "$service_name" stop > /dev/null 2>&1
+	service "$service_name" start || exit $?
+	;;
 
 shutdown)
-        ctdb_service_stop
-        ;;
+	service "$service_name"_stop
+	;;
 
 monitor)
         ctdb_check_unix_socket "$CTDB_CLAMD_SOCKET" || exit $?
diff --git a/ctdb/config/events.d/40.vsftpd b/ctdb/config/events.d/40.vsftpd
index 703edaf..f3c4848 100755
--- a/ctdb/config/events.d/40.vsftpd
+++ b/ctdb/config/events.d/40.vsftpd
@@ -7,16 +7,6 @@
 . "${CTDB_BASE}/functions"
 
 service_name="vsftpd"
-# make sure the service is stopped first
-service_start ()
-{
-    service $service_name stop > /dev/null 2>&1
-    service $service_name start
-}
-service_stop ()
-{
-    service $service_name stop
-}
 
 service_reconfigure ()
 {
@@ -25,17 +15,17 @@ service_reconfigure ()
 
 loadconfig
 
-ctdb_start_stop_service
-
 is_ctdb_managed_service || exit 0
 
 case "$1" in
 startup)
-	ctdb_service_start
+	service "$service_name" stop > /dev/null 2>&1
+	service "$service_name" start
+	ctdb_counter_init
 	;;
 
 shutdown)
-	ctdb_service_stop
+	service "$service_name" stop
 	;;
 
 takeip|releaseip)
diff --git a/ctdb/config/events.d/41.httpd b/ctdb/config/events.d/41.httpd
index 4d04b39..b9aa7e1 100755
--- a/ctdb/config/events.d/41.httpd
+++ b/ctdb/config/events.d/41.httpd
@@ -47,17 +47,16 @@ service_stop ()
 
 loadconfig
 
-ctdb_start_stop_service
-
 is_ctdb_managed_service || exit 0
 
 case "$1" in
 startup)
-	ctdb_service_start
+	service_start
+	ctdb_counter_int
 	;;
 
 shutdown)
-	ctdb_service_stop
+	service_stop
 	;;
 
 monitor)
diff --git a/ctdb/config/events.d/49.winbind b/ctdb/config/events.d/49.winbind
index d95f90f..5e93737 100755
--- a/ctdb/config/events.d/49.winbind
+++ b/ctdb/config/events.d/49.winbind
@@ -34,23 +34,25 @@ service_stop ()
 
 ###########################
 
-ctdb_start_stop_service
-
 is_ctdb_managed_service || exit 0
 
 ###########################
 
 case "$1" in
 startup)
-	ctdb_service_start
+	service_start
 	;;
 
 shutdown)
-	ctdb_service_stop
+	service_stop
 	;;
 
 monitor)
-	ctdb_check_command wbinfo -p
+	if ! out=$(wbinfo -p 2>&1) ; then
+		echo "ERROR: wbinfo -p returned error"
+		echo "$out"
+		exit 1
+	fi
 	;;
 esac
 
diff --git a/ctdb/config/events.d/50.samba b/ctdb/config/events.d/50.samba
index 161a885..4c32e4e 100755
--- a/ctdb/config/events.d/50.samba
+++ b/ctdb/config/events.d/50.samba
@@ -149,19 +149,17 @@ list_samba_ports ()
 
 ###########################
 
-ctdb_start_stop_service
-
 is_ctdb_managed_service || exit 0
 
 ###########################
 
 case "$1" in
 startup)
-	ctdb_service_start
+	service_start
 	;;
 
 shutdown)
-	ctdb_service_stop
+	service_stop
 	;;
 
 monitor)
diff --git a/ctdb/config/events.d/60.nfs b/ctdb/config/events.d/60.nfs
index 02d6e2b..bd6be78 100755
--- a/ctdb/config/events.d/60.nfs
+++ b/ctdb/config/events.d/60.nfs
@@ -250,8 +250,6 @@ nfs_update_lock_info ()
 
 nfs_callout_init "$service_state_dir"
 
-ctdb_start_stop_service
-
 is_ctdb_managed_service || exit 0
 
 case "$1" in
diff --git a/ctdb/config/events.d/70.iscsi b/ctdb/config/events.d/70.iscsi
index 0937a12..8851c59 100755
--- a/ctdb/config/events.d/70.iscsi
+++ b/ctdb/config/events.d/70.iscsi
@@ -13,8 +13,6 @@ service_name="iscsi"
 
 loadconfig
 
-ctdb_start_stop_service
-
 is_ctdb_managed_service || exit 0
 
 [ -z "$CTDB_START_ISCSI_SCRIPTS" ] && {
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 7e37bbb..f453968 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -97,26 +97,6 @@ loadconfig () {
 
 ##############################################################
 
-# CTDB_SCRIPT_DEBUGLEVEL can be overwritten by setting it in a
-# configuration file.
-debug ()
-{
-    if [ "${CTDB_SCRIPT_DEBUGLEVEL:-NOTICE}" = "DEBUG" ] ; then
-	# If there are arguments then echo them.  Otherwise expect to
-	# use stdin, which allows us to pass lots of debug using a
-	# here document.
-	if [ -n "$1" ] ; then
-	    echo "DEBUG: $*"
-	else
-	    sed -e 's@^@DEBUG: @'
-	fi
-    else
-	if [ -z "$1" ] ; then
-	    cat >/dev/null
-	fi
-    fi
-}
-
 die ()
 {
     _msg="$1"
@@ -358,67 +338,40 @@ ctdb_check_directories()
 # usage: ctdb_check_tcp_ports <ports...>
 ######################################################
 
-# This flag file is created when a service is initially started.  It
-# is deleted the first time TCP port checks for that service succeed.
-# Until then ctdb_check_tcp_ports() prints a more subtle "error"
-# message if a port check fails.
-_ctdb_check_tcp_common ()
-{
-    assert_service_name
-    _d="${CTDB_SCRIPT_VARDIR}/failcount"
-    _ctdb_service_started_file="${_d}/${service_name}.started"
-}
-
-ctdb_check_tcp_init ()
-{
-    _ctdb_check_tcp_common
-    mkdir -p "${_ctdb_service_started_file%/*}" # dirname
-    touch "$_ctdb_service_started_file"
-}
-
 # Check whether something is listening on all of the given TCP ports
 # using the "ctdb checktcpport" command.
 ctdb_check_tcp_ports()
 {
-    if [ -z "$1" ] ; then
-	echo "INTERNAL ERROR: ctdb_check_tcp_ports - no ports specified"
-	exit 1
-    fi
-
-    for _p ; do  # process each function argument (port)
-	_cmd="$CTDB checktcpport $_p"
-	_out=$($_cmd 2>&1)
-	_ret=$?
-	case "$_ret" in
-	    0)
-		_ctdb_check_tcp_common
-		if [ ! -f "$_ctdb_service_started_file" ] ; then
-		    echo "ERROR: $service_name tcp port $_p is not responding"
-		    debug "\"ctdb checktcpport $_p\" was able to bind to port"
-		else
-		    echo "INFO: $service_name tcp port $_p is not responding"
-		fi
+	if [ -z "$1" ] ; then
+		echo "INTERNAL ERROR: ctdb_check_tcp_ports - no ports specified"
+		exit 1
+	fi
 
-		return 1
-		;;
-	    98)
-		# Couldn't bind, something already listening, next port...
-		continue
-		;;
-	    *)
-		echo "ERROR: unexpected error running \"ctdb checktcpport\""
-		debug <<EOF
-$CTDB checktcpport (exited with $_ret) with output:
-$_out"
-EOF
-		return $_ret
-	esac
-    done
+	for _p ; do  # process each function argument (port)
+		_cmd="$CTDB checktcpport $_p"
+		_out=$($_cmd 2>&1)
+		_ret=$?
+		case "$_ret" in
+		0)
+			echo "$service_name not listening on TCP port $_p"
+			return 1
+			;;
+		98)
+			# Couldn't bind, something already listening, next port
+			continue
+			;;
+		*)
+			echo "unexpected error (${_ret}) running \"${_cmd}\""
+			if [ -n "$_out" ] ; then
+				echo "$_out"
+			fi
+			return $_ret
+			;;
+		esac
+	done
 
-    # All ports listening
-    _ctdb_check_tcp_common
-    rm -f "$_ctdb_service_started_file"
-    return 0
+	# All ports listening
+	return 0
 }
 
 ######################################################
@@ -435,19 +388,6 @@ ctdb_check_unix_socket() {
     fi
 }
 
-######################################################
-# check a command returns zero status
-# usage: ctdb_check_command <command>
-######################################################
-ctdb_check_command ()
-{
-    _out=$("$@" 2>&1) || {
-	echo "ERROR: $* returned error"
-	echo "$_out" | debug
-	exit 1
-    }
-}
-
 ################################################
 # kill off any TCP connections with the given IP
 ################################################
@@ -782,33 +722,6 @@ ctdb_setup_service_state_dir ()
 	echo "$_service_state_dir"
 }
 
-########################################################
-# Managed status history, for auto-start/stop
-
-_ctdb_managed_common ()
-{
-    _ctdb_managed_file="${CTDB_SCRIPT_VARDIR}/managed_history/${service_name}"
-}
-
-ctdb_service_managed ()
-{
-    _ctdb_managed_common
-    mkdir -p "${_ctdb_managed_file%/*}" # dirname
-    touch "$_ctdb_managed_file"
-}
-
-ctdb_service_unmanaged ()
-{
-    _ctdb_managed_common
-    rm -f "$_ctdb_managed_file"
-}
-
-is_ctdb_previously_managed_service ()
-{
-    _ctdb_managed_common
-    [ -f "$_ctdb_managed_file" ]
-}
-
 ##################################################################
 # Reconfigure a service on demand
 
@@ -854,7 +767,7 @@ service_reconfigure ()
 }
 
 ##################################################################
-# Does CTDB manage this service? - and associated auto-start/stop
+# Does CTDB manage this service?
 
 ctdb_compat_managed_service ()
 {
@@ -893,75 +806,6 @@ is_ctdb_managed_service ()
     [ "${t#* ${service_name} }" != "${t}" ]
 }
 
-ctdb_start_stop_service ()
-{
-    assert_service_name
-
-    # Allow service-start/service-stop pseudo-events to start/stop
-    # services when we're not auto-starting/stopping and we're not
-    # monitoring.
-    case "$event_name" in
-	service-start)
-	    if is_ctdb_managed_service ; then
-		die 'service-start event not permitted when service is managed'
-	    fi
-	    if [ "$CTDB_SERVICE_AUTOSTARTSTOP" = "yes" ] ; then
-		die 'service-start event not permitted with CTDB_SERVICE_AUTOSTARTSTOP=yes'
-	    fi
-	    ctdb_service_start
-	    exit $?
-	    ;;
-	service-stop)
-	    if is_ctdb_managed_service ; then
-		die 'service-stop event not permitted when service is managed'
-	    fi
-	    if [ "$CTDB_SERVICE_AUTOSTARTSTOP" = "yes" ] ; then
-		die 'service-stop event not permitted with CTDB_SERVICE_AUTOSTARTSTOP=yes'
-	    fi
-	    ctdb_service_stop
-	    exit $?
-	    ;;
-    esac
-
-    # Do nothing unless configured to...
-    [ "$CTDB_SERVICE_AUTOSTARTSTOP" = "yes" ] || return 0
-
-    [ "$event_name" = "monitor" ] || return 0
-
-    if is_ctdb_managed_service ; then
-	if ! is_ctdb_previously_managed_service ; then
-	    echo "Starting service \"$service_name\" - now managed"
-	    background_with_logging ctdb_service_start
-	    exit $?
-	fi
-    else
-	if is_ctdb_previously_managed_service ; then
-	    echo "Stopping service \"$service_name\" - no longer managed"
-	    background_with_logging ctdb_service_stop
-	    exit $?
-	fi
-    fi
-}
-
-ctdb_service_start ()
-{
-    # The service is marked managed if we've ever tried to start it.
-    ctdb_service_managed
-
-    service_start || return $?
-
-    # Intentionally have this use $service_name as default
-    # shellcheck disable=SC2119
-    ctdb_counter_init
-    ctdb_check_tcp_init
-}
-
-ctdb_service_stop ()
-{
-    ctdb_service_unmanaged
-    service_stop
-}
-
 # Default service_start() and service_stop() functions.
  
 # These may be overridden in an eventscript.
@@ -1168,4 +1012,3 @@ update_tickles ()
 }
 
 script_name="${0##*/}"       # basename
-event_name="$1"
diff --git a/ctdb/doc/ctdbd.conf.5.xml b/ctdb/doc/ctdbd.conf.5.xml
index bbc02c6..1259fd3 100644
--- a/ctdb/doc/ctdbd.conf.5.xml
+++ b/ctdb/doc/ctdbd.conf.5.xml
@@ -1485,19 +1485,6 @@ CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=9000
 	  </listitem>
 	</varlistentry>
 
-	<varlistentry>
-	  <term>CTDB_SERVICE_AUTOSTARTSTOP=yes|no</term>
-	  <listitem>
-	    <para>
-	      When CTDB should start and stop services if they become
-	      managed or unmanaged.
-	    </para>
-	    <para>
-	      Default is no.
-	    </para>
-	  </listitem>
-	</varlistentry>
-
       </variablelist>
 
     </refsect2>
@@ -1697,20 +1684,6 @@ CTDB_SET_MonitorInterval=20


-- 
Samba Shared Repository



More information about the samba-cvs mailing list