[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Fri Mar 15 06:32:02 UTC 2019


The branch, master has been updated
       via  edd4a23d763 ctdb-version: Simplify version string usage
       via  148306674d0 ctdb-build: Drop creation of .distversion in tarball
       via  05c28fee21c ctdb-build: use a fixed ctdb_version.h using SAMBA_VERSION_STRING
       via  2c3df581329 ctdb-tests: Add a test for version consistency checking
       via  8c2ff3f2b52 ctdb-daemon: Add an environment variable to set version
       via  627a5cf1e71 ctdb-tests: Fix remaining common.sh ShellCheck hits
       via  6555fbce995 ctdb-tests: Shell cleanups in wait_until() function
       via  2fce893b2c8 ctdb-tests: export CTDB_SCRIPTS_TOOLS_BIN_DIR
       via  957c38b65ca ctdb-packaging: Test package requires tcpdump
       via  b2b8dce4fc5 ctdb-packaging: ctdb package should not own system library directory
       via  d9286701cd9 ctdb-tests: Add some testing for IPv4-mapped IPv6 address parsing
       via  539b5ff32b3 ctdb: Initialize addr struct to zero before reparsing as IPV4
       via  a215d2017f9 ctdb-tests: Build cluster mutex path manually
      from  a2c5f8cf41c dbcheck: don't check expired tombstone objects by default anymore

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


- Log -----------------------------------------------------------------
commit edd4a23d7632af51f4d7b4287917b7fa0dced963
Author: Amitay Isaacs <amitay at samba.org>
Date:   Fri Mar 15 12:14:27 2019 +1100

    ctdb-version: Simplify version string usage
    
    There is no need to write SAMBA_VERSION_STRING as CTDB_VERSION_STRING.
    Wherever required use SAMBA_VERSION_STRING directly.
    
    Avoids the confusion with two version.h files.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13789
    
    Signed-off-by: Amitay Isaacs <amitay at samba.org>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Fri Mar 15 06:31:50 UTC 2019 on sn-devel-144

commit 148306674d0e4706adca3e5dcbb779c51a2c03da
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 7 17:53:25 2019 +1100

    ctdb-build: Drop creation of .distversion in tarball
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13789
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 05c28fee21c0cc986cb8301f4199595cdb13faee
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jun 16 12:15:25 2017 +0200

    ctdb-build: use a fixed ctdb_version.h using SAMBA_VERSION_STRING
    
    This way we don't get constant rebuild as SAMBA_VERSION_STRING
    is "4.7.0pre1.DEVELOPERBUILD" for the binaries under bin/
    instead of "4.7.0pre1.GIT.59e51f6".
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13789
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 2c3df58132939bbb17a448ef12d5f376244b7545
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 8 13:32:16 2019 +1100

    ctdb-tests: Add a test for version consistency checking
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at samba.org>

commit 8c2ff3f2b52e679a8e14cf97b5dddd1927a20bd1
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Feb 6 13:57:00 2019 +1100

    ctdb-daemon: Add an environment variable to set version
    
    This can be used to test the version checking logic.  Cache the
    version to avoid re-checking the environment variable each time.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at samba.org>

commit 627a5cf1e717aab65b99eaba4e2efe78307adbf2
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 7 15:46:48 2019 +1100

    ctdb-tests: Fix remaining common.sh ShellCheck hits
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at samba.org>

commit 6555fbce995d3d3a7b162ea49a4a9844e234fed8
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 7 15:40:59 2019 +1100

    ctdb-tests: Shell cleanups in wait_until() function
    
    This file is included by local_daemons.sh, which is not a bash script
    and wait_until() uses the "local" keyword.  Prefixing variable names
    with '_' to indicate that they are local changes a lot of lines in
    this function.  So, fix indentation, potential quoting problems and
    other ShellCheck hits while touching this function.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at samba.org>

commit 2fce893b2c8f63c72c5e0fb177ca61c93317b751
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 7 15:26:27 2019 +1100

    ctdb-tests: export CTDB_SCRIPTS_TOOLS_BIN_DIR
    
    This isn't used anywhere that requires it to be exported, but the lack
    of consistency will cause problems and confusion at some later stage.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at samba.org>

commit 957c38b65ca060eabe1e676f8dfb54839d706155
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 6 19:16:55 2019 +1100

    ctdb-packaging: Test package requires tcpdump
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13838
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at samba.org>

commit b2b8dce4fc56c27ef0131104b316346565369dd7
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 6 14:36:01 2019 +1100

    ctdb-packaging: ctdb package should not own system library directory
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13838
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at samba.org>

commit d9286701cd9253bf3b42cac3d850ae8c23743e6d
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 14 16:32:02 2019 +1100

    ctdb-tests: Add some testing for IPv4-mapped IPv6 address parsing
    
    ctdb_sock_addr values are hashed in some contexts.  This means that
    all of the memory used for the ctdb_sock_addr should be consistent
    regardless of how parsing is done.  The first 2 cases are just sanity
    checks but the 3rd case involving an IPv4-mapped IPv6 address is the
    real target of this test addition.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13839
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at samba.org>

commit 539b5ff32b32b7c75dfaaa119e41f5af6ff1e6fc
Author: Zhu Shangzhong <zhu.shangzhong at zte.com.cn>
Date:   Tue Mar 12 20:49:48 2019 +0800

    ctdb: Initialize addr struct to zero before reparsing as IPV4
    
    Failed to kill the tcp connection that using IPv4-mapped IPv6 address
    (e.g. ctdb_killtcp eth0 ::ffff:192.168.200.44:2049
    ::ffff:192.168.200.45:863).
    
    When the ctdb_killtcp is used to kill the tcp connection, the IPs and
    ports in the connection will be parsed to conn.client and conn.server
    (call stack: main->ctdb_sock_addr_from_string->ip_from_string). In
    the ip_from_string, as we are using IPv4-mapped IPv6 addresses, the
    ipv6_from_string will be used to parse ip to addr.ip6 first. The next
    step the ipv4_from_string will be used to reparse ip to addr.ip.
    
    As a result, the data that dump from conn.server is "2 0 8 1 192 168
    200 44 0 0 0 0 0 0 0 0 0 0 255 255 192 168 200 44 0 0 0 0", the data
    from conn.client is "2 0 3 95 192 168 200 45 0 0 0 0 0 0 0 0 0 0 255 255
    192 168 200 45 0 0 0 0". The connection will be add to conn_list by
    ctdb_connection_list_add. Then the reset_connections_send uses conn_list
    as parameter to start to reset connections in the conn_list.
    
    In the reset_connections_send, the database "connections" will be
    created. The connections from conn_list will be written to the
    database(call db_hash_add), and use the data that dump from conn_client
    and conn_server as key.
    
    In the reset_connections_capture_tcp_handler, the
    ctdb_sys_read_tcp_packet will receive data on the raw socket. And
    extract the IPs and ports from the tcp packet. when extracting IP and
    port, the tcp4_extract OR tcp6_extract will be used. Then we got the
    new conn.client and conn.server. the data that dump from the
    conn.server is "2 0 8 1 192 168 200 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0", the data from conn.client is "2 0 3 95 192 168 200 45 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0". Finally, we use the data as key to check
    if this connection is one being reset(call db_hash_delete). The
    db_hash_delete will return ENOENT. Because the two key that being used
    by db_hash_delete and db_hash_add are different.
    
    So, the TCP RST will be NOT sent for the connection forever. We should
    initialize addr struct to zero before reparsing as IPV4 in the
    ip_from_string.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13839
    
    Signed-off-by: Zhu Shangzhong <zhu.shangzhong at zte.com.cn>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at samba.org>

commit a215d2017f95974913a7e97c25e5fc613bb79c26
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 7 15:53:31 2019 +1100

    ctdb-tests: Build cluster mutex path manually
    
    CTDB_CLUSTER_MUTEX_HELPER can't be depended on because it is only set
    when the tests are not installed and setting it unconditionally for
    this particular use would be wrong.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13800
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at samba.org>

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

Summary of changes:
 ctdb/.gitignore                            |  1 -
 ctdb/common/version.c                      | 20 ---------
 ctdb/common/version.h                      | 18 --------
 ctdb/packaging/RPM/ctdb.spec.in            |  4 +-
 ctdb/protocol/protocol_util.c              |  3 ++
 ctdb/server/ctdb_daemon.c                  |  4 +-
 ctdb/server/ctdb_keepalive.c               | 22 +++++++++-
 ctdb/tests/README                          | 11 +++++
 ctdb/tests/local_daemons.sh                |  3 +-
 ctdb/tests/scripts/common.sh               | 70 +++++++++++++++---------------
 ctdb/tests/scripts/script_install_paths.sh |  1 +
 ctdb/tests/simple/91_version_check.sh      | 65 +++++++++++++++++++++++++++
 ctdb/tests/src/protocol_util_test.c        | 19 ++++++++
 ctdb/tools/ctdb.c                          |  4 +-
 ctdb/wscript                               | 25 +----------
 15 files changed, 164 insertions(+), 106 deletions(-)
 delete mode 100644 ctdb/common/version.c
 delete mode 100644 ctdb/common/version.h
 create mode 100755 ctdb/tests/simple/91_version_check.sh


Changeset truncated at 500 lines:

diff --git a/ctdb/.gitignore b/ctdb/.gitignore
index a634aeb8b45..f0534b3afd1 100644
--- a/ctdb/.gitignore
+++ b/ctdb/.gitignore
@@ -27,7 +27,6 @@ tests/takeover/ctdb_takeover.pyc
 tests/eventscripts/var
 tests/eventscripts/etc/iproute2
 tests/eventscripts/etc-ctdb/policy_routing
-include/ctdb_version.h
 packaging/RPM/ctdb.spec
 doc/*.[1-7]
 doc/*.[1-7].html
diff --git a/ctdb/common/version.c b/ctdb/common/version.c
deleted file mode 100644
index e34e98c09ef..00000000000
--- a/ctdb/common/version.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-   CTDB version string
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "ctdb_version.h"
-
-const char ctdb_version_string[] = CTDB_VERSION_STRING;
diff --git a/ctdb/common/version.h b/ctdb/common/version.h
deleted file mode 100644
index 1cf1c5d0cab..00000000000
--- a/ctdb/common/version.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
-   CTDB version string
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-extern const char ctdb_version_string[];
diff --git a/ctdb/packaging/RPM/ctdb.spec.in b/ctdb/packaging/RPM/ctdb.spec.in
index d25735e06e0..efece159bdc 100644
--- a/ctdb/packaging/RPM/ctdb.spec.in
+++ b/ctdb/packaging/RPM/ctdb.spec.in
@@ -222,7 +222,7 @@ fi
 %{_bindir}/onnode
 %dir %{_libexecdir}/ctdb
 %{_libexecdir}/ctdb/*
-%dir %{_libdir}
+%dir %{_libdir}/ctdb
 %{_libdir}/ctdb/lib*
 %dir %{_datadir}/ctdb/events
 %{_datadir}/ctdb/events/*
@@ -258,7 +258,7 @@ development libraries for ctdb
 Summary: CTDB test suite
 Group: Development/Tools
 Requires: ctdb = %{version}
-Requires: nc
+Requires: nc, tcpdump
 
 %description tests
 test suite for ctdb
diff --git a/ctdb/protocol/protocol_util.c b/ctdb/protocol/protocol_util.c
index 99dbe82404d..f97c64665df 100644
--- a/ctdb/protocol/protocol_util.c
+++ b/ctdb/protocol/protocol_util.c
@@ -252,6 +252,9 @@ static int ip_from_string(const char *str, ctdb_sock_addr *addr)
 		if (memcmp(&addr->ip6.sin6_addr.s6_addr[0],
 			   ipv4_mapped_prefix,
 			   sizeof(ipv4_mapped_prefix)) == 0) {
+                        /* Initialize addr struct to zero before reparsing as IPV4 */
+                        ZERO_STRUCTP(addr);
+
 			/* Reparse as IPv4 */
 			ret = ipv4_from_string(p+1, &addr->ip);
 		}
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index aac331dd1dd..a8691388d4a 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/server/ctdb_daemon.c
@@ -36,7 +36,7 @@
 #include "lib/util/blocking.h"
 #include "lib/util/become_daemon.h"
 
-#include "common/version.h"
+#include "version.h"
 #include "ctdb_private.h"
 #include "ctdb_client.h"
 
@@ -1237,7 +1237,7 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
 
 	ctdb->ctdbd_pid = getpid();
 	DEBUG(DEBUG_ERR, ("Starting CTDBD (Version %s) as PID: %u\n",
-			  ctdb_version_string, ctdb->ctdbd_pid));
+			  SAMBA_VERSION_STRING, ctdb->ctdbd_pid));
 	ctdb_create_pidfile(ctdb);
 
 	/* create a unix domain stream socket to listen to */
diff --git a/ctdb/server/ctdb_keepalive.c b/ctdb/server/ctdb_keepalive.c
index a4569ec2502..b4c9d3731c4 100644
--- a/ctdb/server/ctdb_keepalive.c
+++ b/ctdb/server/ctdb_keepalive.c
@@ -39,7 +39,27 @@
 
 static uint32_t keepalive_version(void)
 {
-	return (SAMBA_VERSION_MAJOR << 16) | SAMBA_VERSION_MINOR;
+	static uint32_t version = 0;
+
+	if (version == 0) {
+		const char *t;
+
+		version = (SAMBA_VERSION_MAJOR << 16) | SAMBA_VERSION_MINOR;
+
+		t = getenv("CTDB_TEST_SAMBA_VERSION");
+		if (t != NULL) {
+			int v;
+
+			v = atoi(t);
+			if (v <= 0) {
+				DBG_WARNING("Failed to parse env var: %s\n", t);
+			} else {
+				version = v;
+			}
+		}
+	}
+
+	return version;
 }
 
 static uint32_t keepalive_uptime(struct ctdb_context *ctdb)
diff --git a/ctdb/tests/README b/ctdb/tests/README
index c911dd8f68d..bbda3313850 100644
--- a/ctdb/tests/README
+++ b/ctdb/tests/README
@@ -162,6 +162,17 @@ Test and debugging variable options
 
 	   Default is no.
 
+       CTDB_TEST_SAMBA_VERSION=VERSION
+
+	    VERSION is a 32-bit number containg the Samba major
+	    version in the most significant 16 bits and the minor
+	    version in the least significant 16 bits.  This can be
+	    used to test CTDB's checking of incompatible versions
+	    without installing an incompatible version.  This is
+	    probably best set like this:
+
+		export CTDB_TEST_SAMBA_VERSION=$(( (4 << 16) | 12 ))
+
        CTDB_VARDIR=DIRECTORY
 	   DIRECTORY containing CTDB files that are modified at runtime.
 
diff --git a/ctdb/tests/local_daemons.sh b/ctdb/tests/local_daemons.sh
index 07cf1e9b135..3c3897feb50 100755
--- a/ctdb/tests/local_daemons.sh
+++ b/ctdb/tests/local_daemons.sh
@@ -193,7 +193,8 @@ local_daemons_setup ()
 
 	_recovery_lock="${directory}/rec.lock"
 	if $_recovery_lock_use_command ; then
-		_recovery_lock="! ${CTDB_CLUSTER_MUTEX_HELPER} ${_recovery_lock}"
+		_helper="${CTDB_SCRIPTS_HELPER_BINDIR}/ctdb_mutex_fcntl_helper"
+		_recovery_lock="! ${_helper} ${_recovery_lock}"
 	fi
 
 	if [ -n "$_socket_wrapper" ] ; then
diff --git a/ctdb/tests/scripts/common.sh b/ctdb/tests/scripts/common.sh
index c1713fa1f89..63df11242e7 100644
--- a/ctdb/tests/scripts/common.sh
+++ b/ctdb/tests/scripts/common.sh
@@ -5,13 +5,13 @@
 # Print a message and exit.
 die ()
 {
-	echo "$1" >&2 ; exit ${2:-1}
+	echo "$1" >&2 ; exit "${2:-1}"
 }
 
 # This expands the most probable problem cases like "." and "..".
 TEST_SUBDIR=$(dirname "$0")
-if [ $(dirname "$TEST_SUBDIR") = "." ] ; then
-	TEST_SUBDIR=$(cd "$TEST_SUBDIR" ; pwd)
+if [ "$(dirname "$TEST_SUBDIR")" = "." ] ; then
+	TEST_SUBDIR=$(cd "$TEST_SUBDIR" && pwd)
 fi
 
 . "${TEST_SCRIPTS_DIR}/script_install_paths.sh"
@@ -29,43 +29,42 @@ fi
 # I is the recheck interval.
 wait_until ()
 {
-    local timeout="$1" ; shift # "$@" is the command...
+	_timeout="$1" ; shift # "$@" is the command...
 
-    local interval=1
-    case "$timeout" in
+	_interval=1
+	case "$_timeout" in
 	*/*)
-	    interval="${timeout#*/}"
-	    timeout="${timeout%/*}"
-    esac
-
-    local negate=false
-    if [ "$1" = "!" ] ; then
-	negate=true
-	shift
-    fi
-
-    echo -n "<${timeout}|"
-    local t=$timeout
-    while [ $t -gt 0 ] ; do
-	local rc=0
-	"$@" || rc=$?
-	if { ! $negate && [ $rc -eq 0 ] ; } || \
-	    { $negate && [ $rc -ne 0 ] ; } ; then
-	    echo "|$(($timeout - $t))|"
-	    echo "OK"
-	    return 0
+		_interval="${_timeout#*/}"
+		_timeout="${_timeout%/*}"
+	esac
+
+	_negate=false
+	if [ "$1" = "!" ] ; then
+		_negate=true
+		shift
 	fi
-	local i
-	for i in $(seq 1 $interval) ; do
-	    echo -n .
+
+	printf '<%d|' "$_timeout"
+	_t="$_timeout"
+	while [ "$_t" -gt 0 ] ; do
+		_rc=0
+		"$@" || _rc=$?
+		if { ! $_negate && [ $_rc -eq 0 ] ; } || \
+			   { $_negate && [ $_rc -ne 0 ] ; } ; then
+			echo "|$((_timeout - _t))|"
+			echo "OK"
+			return 0
+		fi
+		for _i in $(seq 1 "$_interval") ; do
+			printf '.'
+		done
+		_t=$((_t - _interval))
+		sleep "$_interval"
 	done
-	t=$(($t - $interval))
-	sleep $interval
-    done
 
-    echo "*TIMEOUT*"
+	echo "*TIMEOUT*"
 
-    return 1
+	return 1
 }
 
 # setup_ctdb_base <parent> <subdir> [item-to-copy]...
@@ -74,8 +73,9 @@ setup_ctdb_base ()
 	[ $# -ge 2 ] || die "usage: setup_ctdb_base <parent> <subdir> [item]..."
 	# If empty arguments are passed then we attempt to remove /
 	# (i.e. the root directory) below
-	[ -n "$1" -a -n "$2" ] || \
+	if [ -z "$1" ] || [ -z "$2" ] ; then
 		die "usage: setup_ctdb_base <parent> <subdir> [item]..."
+	fi
 
 	_parent="$1"
 	_subdir="$2"
diff --git a/ctdb/tests/scripts/script_install_paths.sh b/ctdb/tests/scripts/script_install_paths.sh
index a75abda248a..d67d3fba19f 100644
--- a/ctdb/tests/scripts/script_install_paths.sh
+++ b/ctdb/tests/scripts/script_install_paths.sh
@@ -36,6 +36,7 @@ export CTDB_SCRIPTS_BASE \
        CTDB_SCRIPTS_BIN_DIR \
        CTDB_SCRIPTS_INIT_SCRIPT \
        CTDB_SCRIPTS_SBIN_DIR \
+       CTDB_SCRIPTS_TOOLS_BIN_DIR \
        CTDB_SCRIPTS_TOOLS_HELPER_DIR \
        CTDB_SCRIPTS_HELPER_BINDIR \
        CTDB_SCRIPTS_DATA_DIR \
diff --git a/ctdb/tests/simple/91_version_check.sh b/ctdb/tests/simple/91_version_check.sh
new file mode 100755
index 00000000000..5329b49b23a
--- /dev/null
+++ b/ctdb/tests/simple/91_version_check.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+test_info()
+{
+    cat <<EOF
+Check that the CTDB version consistency checking operates correctly.
+EOF
+}
+
+. "${TEST_SCRIPTS_DIR}/integration.bash"
+
+set -e
+
+if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
+	echo "SKIPPING this test - only runs against local daemons"
+	exit 0
+fi
+
+ctdb_test_init
+
+cluster_is_healthy
+
+select_test_node_and_ips
+
+try_command_on_node -v "$test_node" ctdb version
+version="$out"
+
+major="${version%%.*}"
+rest="${version#*.}"
+minor="${rest%%.*}"
+
+echo "Node ${test_node} has version ${major}.${minor}"
+
+# Unchanged version - this should work
+export CTDB_TEST_SAMBA_VERSION=$(( (major << 16) | minor ))
+printf '\nRestarting node %d with CTDB_TEST_SAMBA_VERSION=0x%08x\n' \
+       "$test_node" \
+       "$CTDB_TEST_SAMBA_VERSION"
+restart_ctdb_1 "$test_node"
+wait_until_ready
+echo "GOOD: ctdbd restarted successfully on node ${test_node}"
+
+d="$CTDB_SCRIPTS_HELPER_BINDIR"
+try_command_on_node "$test_node" "${d}/ctdb-path" "pidfile" "ctdbd"
+pidfile="$out"
+
+# Changed major version - this should fail
+export CTDB_TEST_SAMBA_VERSION=$(( ((major + 1) << 16) | minor ))
+printf '\nRestarting node %d with CTDB_TEST_SAMBA_VERSION=0x%08x\n' \
+       "$test_node" \
+       "$CTDB_TEST_SAMBA_VERSION"
+restart_ctdb_1 "$test_node"
+echo "Will use PID file ${pidfile} to check for ctdbd exit"
+wait_until 30 ! test -f "$pidfile"
+echo "GOOD: ctdbd exited early on node ${test_node}"
+
+# Changed minor version - this should fail
+export CTDB_TEST_SAMBA_VERSION=$(( (major << 16) | (minor + 1) ))
+printf '\nRestarting node %d with CTDB_TEST_SAMBA_VERSION=0x%08x\n' \
+       "$test_node" \
+       "$CTDB_TEST_SAMBA_VERSION"
+start_ctdb_1 "$test_node"
+echo "Will use PID file ${pidfile} to check for ctdbd exit"
+wait_until 30 ! test -f "$pidfile"
+echo "GOOD: ctdbd exited early on node ${test_node}"
diff --git a/ctdb/tests/src/protocol_util_test.c b/ctdb/tests/src/protocol_util_test.c
index 178ce1d6429..edd2a3411a0 100644
--- a/ctdb/tests/src/protocol_util_test.c
+++ b/ctdb/tests/src/protocol_util_test.c
@@ -52,6 +52,20 @@ static void test_sock_addr_from_string_bad(const char *ip, bool with_port)
 	assert(ret == EINVAL);
 }
 
+static void test_sock_addr_from_string_memcmp(const char *ip1,
+					      const char* ip2)
+{
+	ctdb_sock_addr sa1, sa2;
+	int ret;
+
+	ret = ctdb_sock_addr_from_string(ip1, &sa1, false);
+	assert(ret == 0);
+	ret = ctdb_sock_addr_from_string(ip2, &sa2, false);
+	assert(ret == 0);
+	ret = memcmp(&sa1, &sa2, sizeof(ctdb_sock_addr));
+	assert(ret == 0);
+}
+
 static void test_sock_addr_cmp(const char *ip1, const char *ip2,
 			       bool with_port, int res)
 {
@@ -329,6 +343,11 @@ int main(int argc, char *argv[])
 	test_sock_addr_from_string_bad("junk", false);
 	test_sock_addr_from_string_bad("0.0.0.0:0 trailing junk", true);
 
+	test_sock_addr_from_string_memcmp("127.0.0.1", "127.0.0.1");
+	test_sock_addr_from_string_memcmp("fe80::6af7:28ff:fefa:d136",
+					  "fe80::6af7:28ff:fefa:d136");
+	test_sock_addr_from_string_memcmp("::ffff:192.0.2.128", "192.0.2.128");
+
 	test_sock_addr_cmp("127.0.0.1", "127.0.0.1" , false, 0);
 	test_sock_addr_cmp("127.0.0.1", "127.0.0.2" , false, -1);
 	test_sock_addr_cmp("127.0.0.2", "127.0.0.1" , false, 1);
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 8140d7337c5..6b82bf779a9 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -30,7 +30,7 @@
 #include <tevent.h>
 #include <tdb.h>
 
-#include "common/version.h"
+#include "version.h"
 #include "lib/util/debug.h"
 #include "lib/util/samba_util.h"
 #include "lib/util/sys_rw.h"
@@ -723,7 +723,7 @@ static int run_helper(TALLOC_CTX *mem_ctx, const char *command,
 static int control_version(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
 			   int argc, const char **argv)
 {
-	printf("%s\n", ctdb_version_string);
+	printf("%s\n", SAMBA_VERSION_STRING);
 	return 0;
 }
 
diff --git a/ctdb/wscript b/ctdb/wscript
index c2f1956a916..4adf60046c3 100644
--- a/ctdb/wscript
+++ b/ctdb/wscript
@@ -340,15 +340,6 @@ def configure(conf):
             else:
                 Logs.info("  %s: no" % (m))
 
-def gen_ctdb_version(task):
-    fp = open(task.outputs[0].bldpath(task.env), 'w')
-    fp.write('/* This file is auto-generated from waf */\n')
-    fp.write('#include "version.h"\n')
-    fp.write('\n')
-    fp.write('#define CTDB_VERSION_STRING "%s"\n' % get_version_string())
-    fp.close()
-
-
 def build(bld):
     if bld.env.standalone_ctdb:
         # enable building of public headers in the build tree
@@ -357,12 +348,6 @@ def build(bld):
     if bld.env.standalone_ctdb:
         bld.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir)
 
-    t = bld.SAMBA_GENERATOR('ctdb-version-header',
-                            target='include/ctdb_version.h',
-                            rule=gen_ctdb_version,
-                            dep_vars=['VERSION'])
-    t.env.VERSION = get_version_string()
-
     bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
 
     bld.RECURSE('lib/replace')
@@ -427,7 +412,7 @@ def build(bld):
                                              pidfile.c run_proc.c
                                              hash_count.c
                                              run_event.c event_script.c
-                                             sock_client.c version.c
+                                             sock_client.c
                                              cmdline.c path.c conf.c line.c
                                           '''),
                         deps='''samba-util sys_rw tevent-util
@@ -1181,14 +1166,6 @@ def manpages(ctx):
 def distonly(ctx):
     samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
 
-    version = get_version()
-
-    distfile = open('.distversion', 'w')
-    for field in version.vcs_fields:
-        distfile.write('%s=%s\n' % (field, str(version.vcs_fields[field])))
-    distfile.close()
-    samba_dist.DIST_FILES('ctdb/.distversion:.distversion', extend=True)
-
     t = 'ctdb.spec'
     sed_expr1 = 's/@VERSION@/%s/g' % get_version_string()
     sed_expr2 = 's/@RELEASE@/%s/g' % '1'


-- 
Samba Shared Repository



More information about the samba-cvs mailing list