[SCM] Samba Shared Repository - branch v4-2-test updated

Karolin Seeger kseeger at samba.org
Sun Apr 19 15:45:07 MDT 2015


The branch, v4-2-test has been updated
       via  6352ce7 waf: Fix systemd detection
       via  65c7bc5 build: Move systemd checks to lib/util
       via  9b721b9 spoolss: purge the printer name cache on name change
       via  1d1db40 s3: libsmbclient: After getting attribute server, ensure main srv pointer is still valid.
       via  ec1a40d ctdb-scripts: Fix bashism in ctdbd_wrapper script
       via  9c54ea8 ctdb-scripts: Call iptables/ip6tables directly from iptables_wrapper
       via  4adb57c ctdb-tests: Fix tickle sniffing for IPv4
       via  74db853 ctdb-scripts: Fix tunable setup code by making it shell-agnostic
       via  3aecf28 ctdb-scripts: Don't use the GNU awk gensub() function
       via  6cbfa35 ctdb-scripts: Try to deal with Ubuntu having /usr/sbin/service
       via  e3d3ffd ctdb: check for talloc_asprintf() failure
       via  014c3d9 ctdb: Coverity fix for CID 1291643
       via  b006b7e ctdb: Fix CID 1125615 Copy into fixed size buffer
       via  dd44ac4 ctdb: Fix CID 1125634 Out-of-bounds write
       via  47deea0 ctdb: Fix CID 1125613 Destination buffer too small
       via  265ab2e ctdb: Introduce a helper var in ctdb_get_script_list
       via  9b79fa1 ctdb: Fix memleak in ctdb_get_script_list
       via  a0698ef ctdb: Make for-loop in ctdb_get_script_list more idiomatic
       via  4b2663d ctdb: Fix CID 1288201 Array compared against 0
       via  b2db194 ctdb: Fix 1125553 Buffer not null terminated
       via  663cedd ctdb-tools: Fix heap-use-after-free problem
      from  8acd3c8 VERSION: Bump version up to 4.2.2...

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-2-test


- Log -----------------------------------------------------------------
commit 6352ce70c1d2d3665c2929f4fc4bb313e771f1e2
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Apr 7 16:30:30 2015 +0200

    waf: Fix systemd detection
    
    https://bugzilla.samba.org/show_bug.cgi?id=11200
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    
    (cherry picked from commit 5ee27b4ead57c15db7168d80f6fdf821663c44fc)
    
    Autobuild-User(v4-2-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-2-test): Sun Apr 19 23:44:30 CEST 2015 on sn-devel-104

commit 65c7bc547f0d6d6688bb82a90e11527d2d6969b7
Author: Christof Schmitt <cs at samba.org>
Date:   Fri Mar 20 12:13:14 2015 -0700

    build: Move systemd checks to lib/util
    
    Only lib/util uses the systemd library, so it makes sense to have the
    checks there. This also removes the need for the ctdb build script to
    specify an empty tag for the systemd library.
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (cherry picked from commit 0509790ec3696e09f6d5e6db969e46e8fd975efb)

commit 9b721b97df2235a2d7d9a5d26e319a1495f13630
Author: David Disseldorp <ddiss at samba.org>
Date:   Wed Apr 1 01:03:13 2015 +0200

    spoolss: purge the printer name cache on name change
    
    Currently the name cache is only cleared on printer deletion. This means
    that if a printer undergoes a name change, the old name remains in the
    cache and can be subsequently used incorrecly if another printer takes
    the same name as the old.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11210
    
    Reported-by: Franz Pförtsch <franz.pfoertsch at brose.com>
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Tue Apr 14 05:37:50 CEST 2015 on sn-devel-104
    
    (cherry picked from commit a97507a9a7ba01beead6a621e1210618e93a9f9c)

commit 1d1db40e853d15e016b8ec31bab1059393ce03b3
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Mar 31 14:40:23 2015 -0700

    s3: libsmbclient: After getting attribute server, ensure main srv pointer is still valid.
    
    Bug #11186: Crash seen in libsmbclient due to free of server structure during SMBC_getxattr() call
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11186
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    
    Autobuild-User(master): David Disseldorp <ddiss at samba.org>
    Autobuild-Date(master): Tue Apr 14 02:58:43 CEST 2015 on sn-devel-104
    
    (cherry picked from commit 2d4db4a65e1e8924470741378fe249f22196eceb)

commit ec1a40de0a105a5a8df20f27f70bbeb77bfc8056
Author: Led <ledest at gmail.com>
Date:   Sun Dec 14 21:06:44 2014 +0200

    ctdb-scripts: Fix bashism in ctdbd_wrapper script
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11007
    
    Signed-off-by: Oleksandr Chumachenko <ledest at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit 2c3672f4249a7d3453b7e82ca96b4cd666aae709)

commit 9c54ea8df1a756cf5a752477568fddabeeb238ac
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Dec 30 16:04:00 2014 +1100

    ctdb-scripts: Call iptables/ip6tables directly from iptables_wrapper
    
    Drops the iptables() and ip6tables() functions and, hence, the
    hardcoding of paths /sbin/iptables and /sbin/ip6tables.  The latter
    avoids problems on openSUSE where (for example) /usr/sbin/iptables is
    used instead.
    
    This means that locking around ip*tables commands is only done when
    iptables_wrapper is called directly.  This is fine because the only
    conflict is when "releaseip" or "takeip"/"updateip" events are run in
    parallel.  The other uses in 11.natgw and 70.iscsi are in events where
    there will be no collisions.
    
    Making 11.natgw support IPv6 is unnecessary.  Just put a static IPv6
    address on each interface - they're plentiful.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Wed Jan 28 08:29:55 CET 2015 on sn-devel-104
    
    (cherry picked from commit ab51f283e7a7f4fc82a94d39e7bb3a68e8aac554)
    
    The last 2 patches address
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11203
    
    CTDB has some remaining IPv6-related issues.

commit 4adb57cdb7188f9db339a843894e3942499b681e
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Dec 20 19:54:13 2014 +1100

    ctdb-tests: Fix tickle sniffing for IPv4
    
    tcptickle_sniff_start() assumes that if $dst contains a ': then it
    should use the IPv6 sniffing code.  However, $dst is a socket, so has
    a trailing ":<port>".
    
    Strip the trailing ":<port>" before checking for ':' as a marker for
    an IPv6 address.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit 82aa6bd2f27775f3fd82931d613379d5d618ef70)

commit 74db853ee0db167e666c54ca82d24bb209af1562
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Feb 16 14:04:09 2015 +1100

    ctdb-scripts: Fix tunable setup code by making it shell-agnostic
    
    All tunables set in configuration are currently set to 0 on system
    where /bin/sh is dash (and perhaps other non-bash shells).  dash puts
    single quotes around all values in the output of the "set" builtin
    command, whereas bash only puts them around values when something
    needs to be quoted.  Tunables always have a simple integer value so
    dash will quote them and bash won't.  The setup code currently passes
    the raw value, including any quotes to "ctdb setvar ...".  This
    command does no error checking on the input, so "'1'" is converted to
    0.
    
    Change the code so that the value is determined from the shell
    variable and is independent of the "set" output.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 39686f45056d942de5ebe3263a533a99ca17c79e)
    
    The last 3 patches address
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11202
    
    CTDB has portability issues

commit 3aecf288501e29f6d55f128d5b82f93eb84e6e73
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Dec 19 14:19:32 2014 +1100

    ctdb-scripts: Don't use the GNU awk gensub() function
    
    This is a gawk extension and can't be used reliably if just running
    "awk".  It is simple enough to switch to using the standard sub() and
    gsub() functions.
    
    The alternative is to switch to explicitly running "gawk".  However,
    although the eventscripts aren't exactly portable, it is probably
    better to move closer to portability than further away.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit 4638010abb116aed0c180207aaa11475277aecb7)

commit 6cbfa359fb150cc1e9284d6ace8a3ddee09b5651
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Dec 1 12:21:16 2014 +1100

    ctdb-scripts: Try to deal with Ubuntu having /usr/sbin/service
    
    Falling back to running the initscript doesn't work because it detects
    that upstart is being used and fails.  This was observed when trying
    to start winbind on Ubuntu 11.04.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit a5c5eee7d186d938c5b458cb6dbf0c78cb548b63)

commit e3d3ffd6421d1127e365d9bc820f597af774beae
Author: David Disseldorp <ddiss at samba.org>
Date:   Tue Mar 31 18:06:43 2015 +0200

    ctdb: check for talloc_asprintf() failure
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Wed Apr  1 15:36:03 CEST 2015 on sn-devel-104
    
    (cherry picked from commit 12309f8bfb70878bec5fcec4681eb4e463e07357)
    
    Conflicts:
    	ctdb/tcp/tcp_connect.c
    
    The last 11 patches address
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11201
    
    CTDB contains potential buffer overflows, unchecked memory allocation failures,
    resource leaks.

commit 014c3d9bf41daf94a587c83586450006c1614bf7
Author: Rajesh Joseph <rjoseph at redhat.com>
Date:   Tue Mar 31 18:43:36 2015 +0530

    ctdb: Coverity fix for CID 1291643
    
    CID 1291643: Resource leak: leaked_handle: Handle
    variable lock_fd going out of scope leaks the handle.
    
    Fix: on failure case release handle variable lock_fd
    
    Signed-off-by: Rajesh Joseph <rjoseph at redhat.com>
    Reviewed-by: Michael Adam <obnox at samba.org>
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    (cherry picked from commit 801bdcde6a7a92acfdb26d87a17a33802e166a2d)
    
    Conflicts:
    	ctdb/tcp/tcp_connect.c

commit b006b7e41318b8f76ed468570ab34311e495c6e6
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Mar 26 13:11:14 2015 +0100

    ctdb: Fix CID 1125615 Copy into fixed size buffer
    
    Might be a "can't happen", but strcpy always looks fishy
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit 508b45fca93ca2dfb048fdf7465602bc34df42db)

commit dd44ac46f9969d0943b8a91ce2d1cadfcc1b8ffd
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Mar 26 13:06:26 2015 +0100

    ctdb: Fix CID 1125634 Out-of-bounds write
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit 93d4e801298d8ebb7261adbfc2bdb1a5fbe7115c)

commit 47deea0b75f43df7b6c3f535b21e0f0becb53fba
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Mar 13 14:20:05 2015 +0000

    ctdb: Fix CID 1125613 Destination buffer too small
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Fri Mar 13 19:14:20 CET 2015 on sn-devel-104
    
    (cherry picked from commit d171d2010a256a46446de5328a0897df3838855a)

commit 265ab2ecdede337a644752b7257a43db2739b8b6
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Mar 13 14:16:17 2015 +0000

    ctdb: Introduce a helper var in ctdb_get_script_list
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit 8d9bb5c54aae0099e0dde2d9a904676fcb9340c0)

commit 9b79fa1e3093167906eb399c0f1516ede2939355
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Mar 13 14:12:41 2015 +0000

    ctdb: Fix memleak in ctdb_get_script_list
    
    scandir allocates every name individually, see example code in susv4 or man
    scandir
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit c1e8bfb186c5cbeafbce9f2767db82edb579d5e1)

commit a0698ef6f248dab35d3a98a5159a8ed3daf0c614
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Mar 13 14:11:20 2015 +0000

    ctdb: Make for-loop in ctdb_get_script_list more idiomatic
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit a8cc495b967935852c5357c3a4ef3d37579fb51b)

commit 4b2663d68fae676f6d0674b4ecc18df100e29117
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Mar 11 10:58:11 2015 +0000

    ctdb: Fix CID 1288201 Array compared against 0
    
    "helper_prog" is now declared as a static array
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit f724bfb44a6086a17d90a802c3965a0b9fd09ebd)

commit b2db1948594029c777bf31b284debec5578dd727
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Mar 7 10:29:21 2015 +0000

    ctdb: Fix 1125553 Buffer not null terminated
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ira Cooper <ira at samba.org>
    (cherry picked from commit 621bd0784290f24e229caf0590206805f6f2e75c)

commit 663cedd8e20861809449db06553540008758be9c
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Oct 14 17:52:55 2014 +1100

    ctdb-tools: Fix heap-use-after-free problem
    
    Found by address sanitizer.
    
    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): Fri Oct 17 12:56:02 CEST 2014 on sn-devel-104
    
    (cherry picked from commit 470af881479d1a1588dc23ef40622b4d8f006b61)

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

Summary of changes:
 ctdb/common/system_linux.c                  |  2 +-
 ctdb/config/ctdbd_wrapper                   |  2 +-
 ctdb/config/events.d/00.ctdb                |  6 ++---
 ctdb/config/functions                       | 25 ++++++++----------
 ctdb/config/statd-callout                   |  4 ++-
 ctdb/server/eventscript.c                   | 32 +++++++++++++---------
 ctdb/tcp/tcp_connect.c                      | 24 ++++++++++++-----
 ctdb/tests/complex/18_ctdb_reloadips.sh     |  2 +-
 ctdb/tests/complex/scripts/local.bash       |  2 +-
 ctdb/tests/eventscripts/etc-ctdb/rc.local   |  4 ++-
 ctdb/tests/scripts/integration.bash         |  5 ++--
 ctdb/tests/src/ctdb_takeover_tests.c        |  2 +-
 ctdb/tests/src/ctdb_test_stubs.c            |  7 ++++-
 ctdb/tools/ctdb.c                           |  8 ++++--
 ctdb/wscript                                |  2 --
 lib/util/become_daemon.c                    | 12 ++++-----
 lib/util/wscript                            |  8 ++++++
 lib/util/wscript_build                      |  2 +-
 lib/util/wscript_configure                  | 17 ++++++++++++
 source3/libsmb/libsmb_xattr.c               | 41 +++++++++++++++++++++++++++++
 source3/rpc_server/spoolss/srv_spoolss_nt.c |  6 +++++
 wscript                                     | 22 ----------------
 22 files changed, 156 insertions(+), 79 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c
index 97a57ac..fdb8d12 100644
--- a/ctdb/common/system_linux.c
+++ b/ctdb/common/system_linux.c
@@ -100,7 +100,7 @@ int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface)
 		}
 
 		DEBUG(DEBUG_DEBUG, (__location__ " Created SOCKET FD:%d for sending arp\n", s));
-		strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)-1);
+		strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
 		if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
 			DEBUG(DEBUG_CRIT,(__location__ " interface '%s' not found\n", iface));
 			close(s);
diff --git a/ctdb/config/ctdbd_wrapper b/ctdb/config/ctdbd_wrapper
index c2c5c1a..c35a4a8 100755
--- a/ctdb/config/ctdbd_wrapper
+++ b/ctdb/config/ctdbd_wrapper
@@ -155,7 +155,7 @@ kill_ctdbd ()
 start()
 {
     if _session=$(ctdbd_is_running) ; then
-	echo $"CTDB is already running"
+	echo "CTDB is already running"
 	return 0
     fi
 
diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb
index a0f4102..c3754ae 100755
--- a/ctdb/config/events.d/00.ctdb
+++ b/ctdb/config/events.d/00.ctdb
@@ -121,10 +121,10 @@ update_config_from_tdb() {
 
 set_ctdb_variables () {
     # set any tunables from the config file
-    set | grep ^CTDB_SET_ | cut -d_ -f3- | 
+    set | sed -n '/^CTDB_SET_/s/=.*//p' |
     while read v; do
-	varname=`echo $v | cut -d= -f1`
-	value=`echo $v | cut -d= -f2`
+	varname="${v#CTDB_SET_}"
+	value=$(eval echo "\$$v")
 	ctdb setvar $varname $value || return 1
 	echo "Set $varname to $value"
     done
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 1583bfc..d40c0d6 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -161,6 +161,8 @@ _service ()
 
   if [ -x /sbin/service ]; then
       $_nice /sbin/service "$_service_name" "$_op"
+  elif [ -x /usr/sbin/service ]; then
+      $_nice /usr/sbin/service "$_service_name" "$_op"
   elif [ -x $CTDB_ETCDIR/init.d/$_service_name ]; then
       $_nice $CTDB_ETCDIR/init.d/$_service_name "$_op"
   elif [ -x $CTDB_ETCDIR/rc.d/init.d/$_service_name ]; then
@@ -888,7 +890,7 @@ delete_ip_from_iface()
     }
 }
 
-# If the given IP is hosted then print 2 items: maskbits and iface 
+# If the given IP is hosted then print 2 items: maskbits and iface
 ip_maskbits_iface ()
 {
     _addr="$1"
@@ -900,8 +902,9 @@ ip_maskbits_iface ()
 
     ip addr show to "${_addr}/${_bits}" 2>/dev/null | \
 	awk -v family="${_family}" \
-	    'NR == 1 { iface = gensub(":$", "", 1, $2) } \
-             $1 ~ /inet/ { print gensub(".*/", "", 1, $2), iface, family }'
+	    'NR == 1 { iface = $2; sub(":$", "", iface) } \
+             $1 ~ /inet/ { mask = $2; sub(".*/", "", mask); \
+                           print mask, iface, family }'
 }
 
 drop_ip ()
@@ -1365,23 +1368,17 @@ ctdb_standard_event_handler ()
     esac
 }
 
-# iptables doesn't like being re-entered, so flock-wrap it.
-iptables ()
-{
-	flock -w 30 $CTDB_VARDIR/iptables-ctdb.flock /sbin/iptables "$@"
-}
-ip6tables ()
-{
-	flock -w 30 $CTDB_VARDIR/iptables-ctdb.flock /sbin/ip6tables "$@"
-}
 iptables_wrapper ()
 {
     _family="$1" ; shift
     if [ "$_family" = "inet6" ] ; then
-	ip6tables "$@"
+	_iptables_cmd="ip6tables"
     else
-	iptables "$@"
+	_iptables_cmd="iptables"
     fi
+
+    # iptables doesn't like being re-entered, so flock-wrap it.
+    flock -w 30 "${CTDB_VARDIR}/iptables-ctdb.flock" "$_iptables_cmd" "$@"
 }
 
 # AIX (and perhaps others?) doesn't have mktemp
diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout
index 5e8eb0e..e2a955e 100755
--- a/ctdb/config/statd-callout
+++ b/ctdb/config/statd-callout
@@ -145,7 +145,9 @@ case "$1" in
 	#   server-IP client-IP
 	# but only for the server-IPs that are hosted on this node.
 	sed_expr=$(ctdb ip | tail -n +2 |
-	    awk -v pnn=$pnn 'pnn == $2 { printf "s/^key.*=.*statd-state@\\(%s\\)@\\([^\"]*\\).*/\\1 \\2/p\n", gensub(/\./, "\\\\.", "g", $1) }')
+	    awk -v pnn=$pnn 'pnn == $2 { \
+                ip = $1; gsub(/\./, "\\\\.", ip); \
+                printf "s/^key.*=.*statd-state@\\(%s\\)@\\([^\"]*\\).*/\\1 \\2/p\n", ip }')
 
 	statd_state=$(ctdb catdb ctdb.tdb | sed -n "$sed_expr" | sort)
 	[ -n "$statd_state" ] || exit 0
diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c
index 28bbb54..e3131b3 100644
--- a/ctdb/server/eventscript.c
+++ b/ctdb/server/eventscript.c
@@ -160,7 +160,7 @@ static struct ctdb_scripts_wire *ctdb_get_script_list(struct ctdb_context *ctdb,
 {
 	struct dirent **namelist;
 	struct ctdb_scripts_wire *scripts;
-	int count;
+	int i, count;
 
 	/* scan all directory entries and insert all valid scripts into the 
 	   tree
@@ -178,19 +178,30 @@ static struct ctdb_scripts_wire *ctdb_get_script_list(struct ctdb_context *ctdb,
 				   + sizeof(scripts->scripts[0]) * count);
 	if (scripts == NULL) {
 		DEBUG(DEBUG_ERR, (__location__ " Failed to allocate scripts\n"));
-		free(namelist);
-		return NULL;
+		goto done;
 	}
 	scripts->num_scripts = count;
 
-	for (count = 0; count < scripts->num_scripts; count++) {
-		strcpy(scripts->scripts[count].name, namelist[count]->d_name);
-		scripts->scripts[count].status = 0;
-		if (!check_executable(ctdb->event_script_dir, namelist[count]->d_name)) {
-			scripts->scripts[count].status = -errno;
+	for (i = 0; i < count; i++) {
+		struct ctdb_script_wire *s = &scripts->scripts[i];
+
+		if (strlcpy(s->name, namelist[i]->d_name, sizeof(s->name)) >=
+		    sizeof(s->name)) {
+			s->status = -ENAMETOOLONG;
+			continue;
+		}
+
+		s->status = 0;
+		if (!check_executable(ctdb->event_script_dir,
+				      namelist[i]->d_name)) {
+			s->status = -errno;
 		}
 	}
 
+done:
+	for (i=0; i<count; i++) {
+		free(namelist[i]);
+	}
 	free(namelist);
 	return scripts;
 }
@@ -333,6 +344,7 @@ static int script_status(struct ctdb_scripts_wire *scripts)
 
 	for (i = 0; i < scripts->num_scripts; i++) {
 		switch (scripts->scripts[i].status) {
+		case -ENAMETOOLONG:
 		case -ENOENT:
 		case -ENOEXEC:
 			/* Disabled or missing; that's OK. */
@@ -447,10 +459,6 @@ static void ctdb_run_debug_hung_script(struct ctdb_context *ctdb, struct debug_h
 	const char **argv;
 	int i;
 
-	if (helper_prog == NULL) {
-		return;
-	}
-
 	if (pipe(fd) < 0) {
 		DEBUG(DEBUG_ERR,("Failed to create pipe fd for debug hung script\n"));
 		return;
diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c
index 8a112ff..da4e6e1 100644
--- a/ctdb/tcp/tcp_connect.c
+++ b/ctdb/tcp/tcp_connect.c
@@ -385,22 +385,32 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
 					strerror(errno), errno));
 		}
 	}
-	
+
 	if (i == ctdb->num_nodes) {
 		DEBUG(DEBUG_CRIT,("Unable to bind to any of the node addresses - giving up\n"));
 		goto failed;
 	}
 	ctdb->address.address = talloc_strdup(ctdb, ctdb->nodes[i]->address.address);
+	if (ctdb->address.address == NULL) {
+		ctdb_set_error(ctdb, "Out of memory at %s:%d",
+			       __FILE__, __LINE__);
+		goto failed;
+	}
 	ctdb->address.port    = ctdb->nodes[i]->address.port;
-	ctdb->name = talloc_asprintf(ctdb, "%s:%u", 
-				     ctdb->address.address, 
+	ctdb->name = talloc_asprintf(ctdb, "%s:%u",
+				     ctdb->address.address,
 				     ctdb->address.port);
+	if (ctdb->name == NULL) {
+		ctdb_set_error(ctdb, "Out of memory at %s:%d",
+			       __FILE__, __LINE__);
+		goto failed;
+	}
 	ctdb->pnn = ctdb->nodes[i]->pnn;
-	DEBUG(DEBUG_INFO,("ctdb chose network address %s:%u pnn %u\n", 
-		 ctdb->address.address, 
-		 ctdb->address.port, 
+	DEBUG(DEBUG_INFO,("ctdb chose network address %s:%u pnn %u\n",
+		 ctdb->address.address,
+		 ctdb->address.port,
 		 ctdb->pnn));
-	
+
 	if (listen(ctcp->listen_fd, 10) == -1) {
 		goto failed;
 	}
diff --git a/ctdb/tests/complex/18_ctdb_reloadips.sh b/ctdb/tests/complex/18_ctdb_reloadips.sh
index 13f7c21..71f997c 100755
--- a/ctdb/tests/complex/18_ctdb_reloadips.sh
+++ b/ctdb/tests/complex/18_ctdb_reloadips.sh
@@ -56,7 +56,7 @@ ctdb_ip_info=$(echo "$out" | awk -F'|' 'NR > 1 { print $2, $3, $5 }')
 echo "Getting IP information from interfaces..."
 try_command_on_node all "ip addr show"
 ip_addr_info=$(echo "$out" | \
-    awk '$1 == "inet" { print gensub(/\/.*/, "", "", $2)}')
+    awk '$1 == "inet" { ip = $2; sub(/\/.*/, "", ip); print ip }')
 
 prefix=""
 for b in $(seq 0 255) ; do
diff --git a/ctdb/tests/complex/scripts/local.bash b/ctdb/tests/complex/scripts/local.bash
index 9c41af2..2dd62a8 100644
--- a/ctdb/tests/complex/scripts/local.bash
+++ b/ctdb/tests/complex/scripts/local.bash
@@ -185,7 +185,7 @@ tcptickle_sniff_start ()
     local src="$1"
     local dst="$2"
 
-    case "$dst" in
+    case "${dst%:*}" in
 	*:*) tcp6tickle_sniff_start "$src" "$dst" ;;
 	*)   tcp4tickle_sniff_start "$src" "$dst" ;;
     esac
diff --git a/ctdb/tests/eventscripts/etc-ctdb/rc.local b/ctdb/tests/eventscripts/etc-ctdb/rc.local
index 0dc531f..0291e57 100755
--- a/ctdb/tests/eventscripts/etc-ctdb/rc.local
+++ b/ctdb/tests/eventscripts/etc-ctdb/rc.local
@@ -51,8 +51,10 @@ get_proc ()
     esac
 }
 
-# Always succeeds
+# Always succeed
 iptables () { : ; }
+ip6tables () { : ; }
+iptables_wrapper () { : ; }
 
 # Do not actually background - we want to see the output
 background_with_logging ()
diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash
index 0d27c93..139a9a2 100644
--- a/ctdb/tests/scripts/integration.bash
+++ b/ctdb/tests/scripts/integration.bash
@@ -699,8 +699,9 @@ ip_maskbits_iface ()
 
     ip addr show to "${_addr}/${_bits}" 2>/dev/null | \
 	awk -v family="${_family}" \
-	    'NR == 1 { iface = gensub(":$", "", 1, $2) } \
-             $1 ~ /inet/ { print gensub(".*/", "", 1, $2), iface, family }'
+	    'NR == 1 { iface = $2; sub(":$", "", iface) } \
+             $1 ~ /inet/ { mask = $2; sub(".*/", "", mask); \
+                           print mask, iface, family }'
 }
 
 drop_ip ()
diff --git a/ctdb/tests/src/ctdb_takeover_tests.c b/ctdb/tests/src/ctdb_takeover_tests.c
index 8b07325..7ff8755 100644
--- a/ctdb/tests/src/ctdb_takeover_tests.c
+++ b/ctdb/tests/src/ctdb_takeover_tests.c
@@ -431,7 +431,7 @@ static void ctdb_test_init(const char nodestates[],
 	while (tok != NULL) {
 		nodeflags[numnodes] = (uint32_t) strtol(tok, NULL, 0);
 		numnodes++;
-		if (numnodes > CTDB_TEST_MAX_NODES) {
+		if (numnodes >= CTDB_TEST_MAX_NODES) {
 			DEBUG(DEBUG_ERR, ("ERROR: Exceeding CTDB_TEST_MAX_NODES: %d\n", CTDB_TEST_MAX_NODES));
 			exit(1);
 		}
diff --git a/ctdb/tests/src/ctdb_test_stubs.c b/ctdb/tests/src/ctdb_test_stubs.c
index 82e82f3..c57f6ca 100644
--- a/ctdb/tests/src/ctdb_test_stubs.c
+++ b/ctdb/tests/src/ctdb_test_stubs.c
@@ -515,7 +515,12 @@ int32_t ctdb_control_get_ifaces(struct ctdb_context *ctdb,
 
 	i = 0;
 	for (cur=ctdb->ifaces;cur;cur=cur->next) {
-		strcpy(ifaces->ifaces[i].name, cur->name);
+		size_t nlen = strlcpy(ifaces->ifaces[i].name, cur->name,
+				      sizeof(ifaces->ifaces[i].name));
+		if (nlen >= sizeof(ifaces->ifaces[i].name)) {
+			/* Ignore invalid name */
+			continue;
+		}
 		ifaces->ifaces[i].link_state = cur->link_up;
 		ifaces->ifaces[i].references = cur->references;
 		i++;
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 6414c24..c386d35 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -928,6 +928,7 @@ static int find_node_xpnn(void)
 	TALLOC_CTX *mem_ctx = talloc_new(NULL);
 	struct pnn_node *pnn_nodes;
 	struct pnn_node *pnn_node;
+	int pnn;
 
 	pnn_nodes = read_nodes_file(mem_ctx);
 	if (pnn_nodes == NULL) {
@@ -938,8 +939,9 @@ static int find_node_xpnn(void)
 
 	for(pnn_node=pnn_nodes;pnn_node;pnn_node=pnn_node->next) {
 		if (ctdb_sys_have_ip(&pnn_node->addr)) {
+			pnn = pnn_node->pnn;
 			talloc_free(mem_ctx);
-			return pnn_node->pnn;
+			return pnn;
 		}
 	}
 
@@ -1850,6 +1852,7 @@ find_other_host_for_public_ip(struct ctdb_context *ctdb, ctdb_sock_addr *addr)
 	struct ctdb_all_public_ips *ips;
 	struct ctdb_node_map *nodemap=NULL;
 	int i, j, ret;
+	int pnn;
 
 	ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE, tmp_ctx, &nodemap);
 	if (ret != 0) {
@@ -1875,8 +1878,9 @@ find_other_host_for_public_ip(struct ctdb_context *ctdb, ctdb_sock_addr *addr)
 
 		for (j=0;j<ips->num;j++) {
 			if (ctdb_same_ip(addr, &ips->ips[j].addr)) {
+				pnn = nodemap->nodes[i].pnn;
 				talloc_free(tmp_ctx);
-				return nodemap->nodes[i].pnn;
+				return pnn;
 			}
 		}
 		talloc_free(ips);
diff --git a/ctdb/wscript b/ctdb/wscript
index 3e2a992..6f5f469 100755
--- a/ctdb/wscript
+++ b/ctdb/wscript
@@ -212,8 +212,6 @@ def configure(conf):
             conf.ADD_EXTRA_INCLUDES('#ctdb')
         conf.ADD_EXTRA_INCLUDES('#lib #lib/replace')
 
-        conf.SET_TARGET_TYPE('systemd-daemon', 'EMPTY')
-
         del(conf.env.defines['PYTHONDIR'])
         del(conf.env.defines['PYTHONARCHDIR'])
 
diff --git a/lib/util/become_daemon.c b/lib/util/become_daemon.c
index 78bebfc..4622971 100644
--- a/lib/util/become_daemon.c
+++ b/lib/util/become_daemon.c
@@ -24,7 +24,7 @@
 #include "includes.h"
 #include "system/filesys.h"
 #include "system/locale.h"
-#if HAVE_SYSTEMD
+#if HAVE_LIBSYSTEMD_DAEMON
 #include <systemd/sd-daemon.h>
 #endif
 #include "lib/util/close_low_fd.h"
@@ -69,9 +69,9 @@ _PUBLIC_ void become_daemon(bool do_fork, bool no_process_group, bool log_stdout
 	if (do_fork) {
 		newpid = fork();
 		if (newpid) {
-#if HAVE_SYSTEMD
+#if HAVE_LIBSYSTEMD_DAEMON
 			sd_notifyf(0, "READY=0\nSTATUS=Starting process...\nMAINPID=%lu", (unsigned long) newpid);
-#endif /* HAVE_SYSTEMD */
+#endif /* HAVE_LIBSYSTEMD_DAEMON */
 			_exit(0);
 		}
 	}
@@ -98,7 +98,7 @@ _PUBLIC_ void become_daemon(bool do_fork, bool no_process_group, bool log_stdout
 
 _PUBLIC_ void exit_daemon(const char *msg, int error)
 {
-#ifdef HAVE_SYSTEMD
+#ifdef HAVE_LIBSYSTEMD_DAEMON
 	if (msg == NULL) {
 		msg = strerror(error);
 	}
@@ -117,7 +117,7 @@ _PUBLIC_ void daemon_ready(const char *name)
 	if (name == NULL) {
 		name = "Samba";
 	}
-#ifdef HAVE_SYSTEMD
+#ifdef HAVE_LIBSYSTEMD_DAEMON
 	sd_notifyf(0, "READY=1\nSTATUS=%s: ready to serve connections...", name);
 #endif
 	DEBUG(0, ("STATUS=daemon '%s' finished starting up and ready to serve "
@@ -129,7 +129,7 @@ _PUBLIC_ void daemon_status(const char *name, const char *msg)
 	if (name == NULL) {
 		name = "Samba";
 	}
-#ifdef HAVE_SYSTEMD
+#ifdef HAVE_LIBSYSTEMD_DAEMON
 	sd_notifyf(0, "\nSTATUS=%s: %s", name, msg);
 #endif
 	DEBUG(0, ("STATUS=daemon '%s' : %s", name, msg));
diff --git a/lib/util/wscript b/lib/util/wscript
index d296e75..2371689 100644
--- a/lib/util/wscript
+++ b/lib/util/wscript
@@ -1,3 +1,11 @@
 def set_options(opt):
     ''' This is a bit strange, but disable is the flag, not enable. '''
     opt.add_option('--disable-fault-handling', action='store_true', dest='disable_fault_handling', help=('disable the fault handlers'), default=False)
+
+    opt.add_option('--with-systemd',
+                   help=("Enable systemd integration"),
+                   action='store_true', dest='enable_systemd')
+
+    opt.add_option('--without-systemd',
+                   help=("Disable systemd integration"),
+                   action='store_false', dest='enable_systemd')
diff --git a/lib/util/wscript_build b/lib/util/wscript_build
index 5db7e35..cb9e8e5 100755
--- a/lib/util/wscript_build
+++ b/lib/util/wscript_build
@@ -54,7 +54,7 @@ if not bld.env.SAMBA_UTIL_CORE_ONLY:
                     tevent_debug.c util_process.c memcache.c''',
                   deps='samba-util-core DYNCONFIG close-low-fd tini tiniparser',
 
-                  public_deps='talloc tevent execinfo pthread LIBCRYPTO charset util_setid systemd-daemon',
+                  public_deps='talloc tevent execinfo pthread LIBCRYPTO charset util_setid systemd systemd-daemon',
                   public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h xfile.h dlinklist.h samba_util.h string_wrappers.h idtree.h idtree_random.h blocking.h signal.h substitute.h fault.h',
                   header_path= [ ('dlinklist.h samba_util.h', '.'), ('*', 'util') ],
                   local_include=False,
diff --git a/lib/util/wscript_configure b/lib/util/wscript_configure
index 1270ab3..8d8dc87 100644
--- a/lib/util/wscript_configure
+++ b/lib/util/wscript_configure
@@ -99,3 +99,20 @@ conf.CHECK_CODE('struct statvfs buf; buf.f_flags = 0',
                 headers='sys/statvfs.h',
                 local_include=False,
                 execute=False)
+
+#
+# systemd removed the libsystemd-daemon and libsystemd-journal libraries. In newer
+# versions it is only libsystemd. As waf pkg-config handling does not provide
+# targets which could be used as a dependency based on the package name we need
+# to look for them on our own. This enabled one of the library targets based on
+# which version we detect.
+#
+conf.SET_TARGET_TYPE('systemd-daemon', 'EMPTY')
+conf.SET_TARGET_TYPE('systemd-journal', 'EMPTY')
+conf.SET_TARGET_TYPE('systemd', 'EMPTY')
+
+if Options.options.enable_systemd != False:
+    conf.check_cfg(package='libsystemd-daemon', args='--cflags --libs',
+                   msg='Checking for libsystemd-daemon')
+    if not conf.CHECK_LIB('systemd-daemon', shlib=True):
+        conf.CHECK_LIB('systemd', shlib=True)
diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c
index 8493776..9f7bea8 100644
--- a/source3/libsmb/libsmb_xattr.c
+++ b/source3/libsmb/libsmb_xattr.c
@@ -2073,6 +2073,25 @@ SMBC_getxattr_ctx(SMBCCTX *context,
         if (! srv->no_nt_session) {
                 ipc_srv = SMBC_attr_server(frame, context, server, port, share,
                                            &workgroup, &user, &password);
+		/*
+		 * SMBC_attr_server() can cause the original
+		 * server to be removed from the cache.
+		 * If so we must error out here as the srv
+		 * pointer has been freed.
+		 */


-- 
Samba Shared Repository


More information about the samba-cvs mailing list