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

Karolin Seeger kseeger at samba.org
Tue Jan 14 10:29:05 UTC 2020


The branch, v4-11-test has been updated
       via  ee215ff101d ctdb-tests: Skip some tests that don't work with IPv6
       via  103d94566f1 ctdb-scripts: Strip square brackets when gathering connection info
       via  890513b5b3c librpc: Fix string length checking in ndr_pull_charset_to_null()
       via  1d28d27070a source4/utils/oLschema2ldif: include stdint.h before cmocka.h
       via  3889444e008 lib/ldb/tests: include stdint.h before cmocka.h
       via  67e429d86ae vfs_ceph_snapshots: fix root relative path handling
       via  54a028bd32b upgradedns: ensure lmdb lock files linked
       via  75d088aede5 test upgradedns: ensure lmdb lock files linked
       via  276a07d8eff docs-xml/winbindnssinfo: clarify interaction with idmap_ad etc.
      from  3659b26bcb4 s3: VFS: glusterfs: Reset nlinks for symlink entries during readdir

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


- Log -----------------------------------------------------------------
commit ee215ff101d6e3de23264fbbca9c9753a4751413
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Nov 28 14:00:58 2019 +1100

    ctdb-tests: Skip some tests that don't work with IPv6
    
    See the comments added to the tests.
    
    It may be possible to rewrite these so they do something sane for
    IPv6... some other time.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14227
    RN: Fix IPv6 issues (NFS connection tracking, tests)
    
    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): Fri Jan  3 00:00:55 UTC 2020 on sn-devel-184
    
    (backported from commit 9edf15afc219a1a782ec1e4d29909361bbabc744)
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    Autobuild-User(v4-11-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-11-test): Tue Jan 14 10:28:01 UTC 2020 on sn-devel-184

commit 103d94566f15d2fdf880cfb5f654896c67d02a42
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Dec 13 11:09:04 2019 +1100

    ctdb-scripts: Strip square brackets when gathering connection info
    
    ss added square brackets around IPv6 addresses in versions > 4.12.0
    via commit aba9c23a6e1cb134840c998df14888dca469a485.  CentOS 7 added
    this feature somewhere mid-release.  So, backward compatibility is
    obviously needed.
    
    As per the comment protocol/protocol_util.c should probably print and
    parse such square brackets.  However, for backward compatibility the
    brackets would have to be stripped in both places in
    update_tickles()...  or added to the ss output when missing.  Best to
    leave this until we have a connection tracking daemon.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14227
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 693080abe4d8bec96280af5a6aa668251a98ec5d)

commit 890513b5b3cf8c8b14fc21c1f095b9d4a3f94e04
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Dec 16 15:50:17 2019 +0100

    librpc: Fix string length checking in ndr_pull_charset_to_null()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14219
    
    Pair-Programmed-With: Guenther Deschner <gd at samba.org>
    Signed-off-by: Guenther Deschner <gd at samba.org>
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit f11e207e01c52566c47e350ff240fe95392de0c3)

commit 1d28d27070a7ade82283dab11c9ef7cadfbf54fb
Author: Fabrice Fontaine <fontaine.fabrice at gmail.com>
Date:   Mon Dec 16 10:28:53 2019 +0100

    source4/utils/oLschema2ldif: include stdint.h before cmocka.h
    
    This fix the following build failure:
    
    In file included from /home/fabrice/buildroot/output/host/opt/ext-toolchain/lib/gcc/mips64el-buildroot-linux-uclibc/5.5.0/include/stdint.h:9:0,
                     from /home/fabrice/buildroot/output/host/mips64el-buildroot-linux-uclibc/sysroot/usr/include/inttypes.h:27,
                     from ../../lib/replace/../replace/replace.h:64,
                     from ../../source4/include/includes.h:23,
                     from ../../source4/utils/oLschema2ldif/test.c:25:
    /home/fabrice/buildroot/output/host/mips64el-buildroot-linux-uclibc/sysroot/usr/include/stdint.h:122:27: error: conflicting types for ‘uintptr_t’
     typedef unsigned long int uintptr_t;
                               ^
    In file included from ../../source4/utils/oLschema2ldif/test.c:23:0:
    /home/fabrice/buildroot/output/host/mips64el-buildroot-linux-uclibc/sysroot/usr/include/cmocka.h:132:28: note: previous declaration of ‘uintptr_t’ was here
           typedef unsigned int uintptr_t;
    
    Fixes:
     - http://autobuild.buildroot.org/results/9507739b3d5d51024ee9c60b74c2f85d5004e7e2
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14218
    
    Signed-off-by: Fabrice Fontaine <fontaine.fabrice at gmail.com>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Wed Dec 18 16:57:52 UTC 2019 on sn-devel-184
    
    (cherry picked from commit 1bfb384018deb2ee5c27dbea9fa2cdd98901fdcc)

commit 3889444e00866eafebcdfb42be5f07990b881c56
Author: Fabrice Fontaine <fontaine.fabrice at gmail.com>
Date:   Sun Dec 15 17:08:24 2019 +0100

    lib/ldb/tests: include stdint.h before cmocka.h
    
    This fix the following build failures:
    
    [2466/3864] Linking bin/default/lib/ldb/ldbmodify
    In file included from /home/buildroot/autobuild/instance-0/output-1/host/opt/ext-toolchain/lib/gcc/mips64el-buildroot-linux-uclibc/5.5.0/include/stdint.h:9:0,
                     from ../../lib/tevent/tevent.h:31,
                     from ../../lib/ldb/include/ldb.h:51,
                     from ../../lib/ldb/tests/test_ldb_dn.c:25:
    /home/buildroot/autobuild/instance-0/output-1/host/mips64el-buildroot-linux-uclibc/sysroot/usr/include/stdint.h:122:27: error: conflicting types for 'uintptr_t'
     typedef unsigned long int uintptr_t;
                               ^
    In file included from ../../lib/ldb/tests/test_ldb_dn.c:23:0:
    /home/buildroot/autobuild/instance-0/output-1/host/mips64el-buildroot-linux-uclibc/sysroot/usr/include/cmocka.h:132:28: note: previous declaration of 'uintptr_t' was here
           typedef unsigned int uintptr_t;
                                ^
    
    In file included from /home/buildroot/autobuild/instance-0/output-1/host/opt/ext-toolchain/lib/gcc/mips64el-buildroot-linux-uclibc/5.5.0/include/stdint.h:9:0,
                     from ../../lib/tevent/tevent.h:31,
                     from ../../lib/ldb/tests/ldb_key_value_test.c:48:
    /home/buildroot/autobuild/instance-0/output-1/host/mips64el-buildroot-linux-uclibc/sysroot/usr/include/stdint.h:122:27: error: conflicting types for 'uintptr_t'
     typedef unsigned long int uintptr_t;
                               ^
    In file included from ../../lib/ldb/tests/ldb_key_value_test.c:43:0:
    /home/buildroot/autobuild/instance-0/output-1/host/mips64el-buildroot-linux-uclibc/sysroot/usr/include/cmocka.h:132:28: note: previous declaration of 'uintptr_t' was here
           typedef unsigned int uintptr_t;
                                ^
    
    Fixes:
     - http://autobuild.buildroot.org/results/9507739b3d5d51024ee9c60b74c2f85d5004e7e2
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14218
    
    Signed-off-by: Fabrice Fontaine <fontaine.fabrice at gmail.com>
    Reviewed-by: Uri Simchoni <uri at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit f8799bf076d647d73aa749f3864d022a366c3904)

commit 67e429d86aed47f36a2bf8c05ae2e47e356bfa12
Author: David Disseldorp <ddiss at samba.org>
Date:   Thu Dec 12 22:14:50 2019 +0100

    vfs_ceph_snapshots: fix root relative path handling
    
    For file paths relative to root, ceph_snap_get_parent_path() may return
    an empty parent dir string, in which case the CephFS snashot path should
    be ".snap".
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=14216
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 54293f92cd83efc3a5a78fc29a85643921da9d32)

commit 54a028bd32b41e1ba7e10b3f64877494a121d655
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Thu Dec 19 16:31:46 2019 +1300

    upgradedns: ensure lmdb lock files linked
    
    Ensure that the '-lock' files for the dns partitions as well as the data
    files are linked when running
      samba_dnsupgrade --dns-backend=BIND9_DLZ
    failure to create these links can cause corruption of the corresponding
    data file.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14199
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 0bd479140c18ab79479ced4f25f366744c3afe18)

commit 75d088aede531bfe721c397fd1900cc26095b9f3
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Thu Dec 19 16:31:24 2019 +1300

    test upgradedns: ensure lmdb lock files linked
    
    Add tests to check that the '-lock' files for the dns partitions as well as
    the data files are linked when running
        samba_dnsupgrade --dns-backend=BIND9_DLZ
    failure to create these links can cause corruption of the corresponding
    data file.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14199
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit f0cebbe4dd0317e2abfcbe252977383e6f37f3bd)

commit 276a07d8eff6273734437ed5acb2ec1217cf7cd2
Author: Björn Jacke <bjacke at samba.org>
Date:   Tue Jan 7 10:21:18 2020 +0100

    docs-xml/winbindnssinfo: clarify interaction with idmap_ad etc.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14122
    RN: docs: clarify interaction between winbind nss info and idmap backend
    
    Signed-off-by: Bjoern Jacke <bjacke at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Wed Jan  8 15:37:46 UTC 2020 on sn-devel-184
    
    (cherry picked from commit 55fbd4c05b477e95920b53b94eda2572e075e6e1)

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

Summary of changes:
 ctdb/config/functions                          |  6 +++
 ctdb/tests/complex/60_rogueip_releaseip.sh     | 10 ++++
 ctdb/tests/complex/61_rogueip_takeip.sh        | 14 +++++
 docs-xml/smbdotconf/winbind/winbindnssinfo.xml |  9 ++--
 lib/ldb/tests/ldb_key_value_sub_txn_test.c     |  1 +
 lib/ldb/tests/ldb_key_value_test.c             |  1 +
 lib/ldb/tests/ldb_lmdb_size_test.c             |  1 +
 lib/ldb/tests/ldb_lmdb_test.c                  |  1 +
 lib/ldb/tests/ldb_no_lmdb_test.c               |  1 +
 lib/ldb/tests/test_ldb_dn.c                    |  1 +
 librpc/ndr/ndr_string.c                        | 49 ++++++++++++++++-
 python/samba/provision/sambadns.py             | 10 ++++
 python/samba/tests/samba_upgradedns_lmdb.py    | 75 ++++++++++++++++++++++++++
 source3/modules/vfs_ceph_snapshots.c           | 14 +++--
 source4/selftest/tests.py                      |  2 +
 source4/utils/oLschema2ldif/test.c             |  1 +
 16 files changed, 186 insertions(+), 10 deletions(-)
 create mode 100644 python/samba/tests/samba_upgradedns_lmdb.py


Changeset truncated at 500 lines:

diff --git a/ctdb/config/functions b/ctdb/config/functions
index 1dc16532890..2e9c3ef6bf0 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -977,10 +977,16 @@ update_tickles ()
 	_my_connections="${tickledir}/${_port}.connections.$$"
 	# Parentheses are needed around the filters for precedence but
 	# the parentheses can't be empty!
+	#
+	# Recent versions of ss print square brackets around IPv6
+	# addresses.  While it is desirable to update CTDB's address
+	# parsing and printing code, something needs to be done here
+	# for backward compatibility, so just delete the brackets.
 	ss -tn state established \
 	   "${_ip_filter:+( ${_ip_filter} )}" \
 	   "${_port_filter:+( ${_port_filter} )}" |
 	awk 'NR > 1 {print $4, $3}' |
+	tr -d '][' |
 	sort >"$_my_connections"
 
 	# Record our current tickles in a temporary file
diff --git a/ctdb/tests/complex/60_rogueip_releaseip.sh b/ctdb/tests/complex/60_rogueip_releaseip.sh
index 88e4e554c34..99d0d406e6f 100755
--- a/ctdb/tests/complex/60_rogueip_releaseip.sh
+++ b/ctdb/tests/complex/60_rogueip_releaseip.sh
@@ -21,6 +21,16 @@ select_test_node_and_ips
 
 echo "Using $test_ip, which is onnode $test_node"
 
+# This test depends on being able to assign a duplicate address on a
+# 2nd node.  However, IPv6 guards against this and causes the test to
+# fail.
+case "$test_ip" in
+*:*)
+	echo "SKIPPING TEST: not supported for IPv6 addresses"
+	exit 0
+	;;
+esac
+
 get_test_ip_mask_and_iface
 
 echo "Finding another node that knows about $test_ip"
diff --git a/ctdb/tests/complex/61_rogueip_takeip.sh b/ctdb/tests/complex/61_rogueip_takeip.sh
index 2c5f7c5c999..e1981eba572 100755
--- a/ctdb/tests/complex/61_rogueip_takeip.sh
+++ b/ctdb/tests/complex/61_rogueip_takeip.sh
@@ -21,6 +21,20 @@ select_test_node_and_ips
 
 echo "Running test against node $test_node and IP $test_ip"
 
+# This test puts an address on an interface and then needs to quickly
+# configure that address and cause an IP takeover.  However, an IPv6
+# address will be tentative for a while so "quickly" is not possible".
+# When ctdb_control_takeover_ip() calls ctdb_sys_have_ip() it will
+# decide that the address is not present.  It then attempts a takeip,
+# which can fail if the address is suddenly present because it is no
+# longer tentative.
+case "$test_ip" in
+*:*)
+	echo "SKIPPING TEST: not supported for IPv6 addresses"
+	exit 0
+	;;
+esac
+
 get_test_ip_mask_and_iface
 
 echo "Deleting IP $test_ip from all nodes"
diff --git a/docs-xml/smbdotconf/winbind/winbindnssinfo.xml b/docs-xml/smbdotconf/winbind/winbindnssinfo.xml
index d8347442a8d..e6d17c256a1 100644
--- a/docs-xml/smbdotconf/winbind/winbindnssinfo.xml
+++ b/docs-xml/smbdotconf/winbind/winbindnssinfo.xml
@@ -22,11 +22,10 @@
 			Domain Controller does support the Microsoft "Services for Unix" (SFU)
 			LDAP schema, winbind can retrieve the login shell and the home
 			directory attributes directly from your Directory Server. For SFU 3.0 or 3.5 simply choose
-			"sfu", if you use SFU 2.0 please choose "sfu20". Note that
-			retrieving UID and GID from your ADS-Server requires to
-			use <parameter moreinfo="none">idmap config DOMAIN:backend</parameter> = ad
-			as well. The primary group membership is currently
-			always calculated via the "primaryGroupID" LDAP attribute.
+			"sfu", if you use SFU 2.0 please choose "sfu20".</para>
+			<para>Note that for the idmap backend <refentrytitle>idmap_ad</refentrytitle>
+			you need to configure those settings in the idmap configuration section.
+			Make sure to consult the documentation of the idmap backend that you are using.
 			</para>
 		</listitem>
 	</itemizedlist>
diff --git a/lib/ldb/tests/ldb_key_value_sub_txn_test.c b/lib/ldb/tests/ldb_key_value_sub_txn_test.c
index e71f81b866e..1eafd2d79e9 100644
--- a/lib/ldb/tests/ldb_key_value_sub_txn_test.c
+++ b/lib/ldb/tests/ldb_key_value_sub_txn_test.c
@@ -37,6 +37,7 @@
  */
 #include <stdarg.h>
 #include <stddef.h>
+#include <stdint.h>
 #include <setjmp.h>
 #include <cmocka.h>
 
diff --git a/lib/ldb/tests/ldb_key_value_test.c b/lib/ldb/tests/ldb_key_value_test.c
index 3f31bb98350..458452e5dc4 100644
--- a/lib/ldb/tests/ldb_key_value_test.c
+++ b/lib/ldb/tests/ldb_key_value_test.c
@@ -39,6 +39,7 @@
  */
 #include <stdarg.h>
 #include <stddef.h>
+#include <stdint.h>
 #include <setjmp.h>
 #include <cmocka.h>
 
diff --git a/lib/ldb/tests/ldb_lmdb_size_test.c b/lib/ldb/tests/ldb_lmdb_size_test.c
index af015fa72b5..cd7ab03a1f0 100644
--- a/lib/ldb/tests/ldb_lmdb_size_test.c
+++ b/lib/ldb/tests/ldb_lmdb_size_test.c
@@ -43,6 +43,7 @@
  */
 #include <stdarg.h>
 #include <stddef.h>
+#include <stdint.h>
 #include <setjmp.h>
 #include <cmocka.h>
 
diff --git a/lib/ldb/tests/ldb_lmdb_test.c b/lib/ldb/tests/ldb_lmdb_test.c
index 78758bbbe16..798a1916281 100644
--- a/lib/ldb/tests/ldb_lmdb_test.c
+++ b/lib/ldb/tests/ldb_lmdb_test.c
@@ -40,6 +40,7 @@
  */
 #include <stdarg.h>
 #include <stddef.h>
+#include <stdint.h>
 #include <setjmp.h>
 #include <cmocka.h>
 
diff --git a/lib/ldb/tests/ldb_no_lmdb_test.c b/lib/ldb/tests/ldb_no_lmdb_test.c
index 8e5a6eee8d2..be23d744004 100644
--- a/lib/ldb/tests/ldb_no_lmdb_test.c
+++ b/lib/ldb/tests/ldb_no_lmdb_test.c
@@ -40,6 +40,7 @@
  */
 #include <stdarg.h>
 #include <stddef.h>
+#include <stdint.h>
 #include <setjmp.h>
 #include <cmocka.h>
 
diff --git a/lib/ldb/tests/test_ldb_dn.c b/lib/ldb/tests/test_ldb_dn.c
index 05f30e4ac67..000ffa72796 100644
--- a/lib/ldb/tests/test_ldb_dn.c
+++ b/lib/ldb/tests/test_ldb_dn.c
@@ -19,6 +19,7 @@
 
 #include <stdarg.h>
 #include <stddef.h>
+#include <stdint.h>
 #include <setjmp.h>
 #include <cmocka.h>
 
diff --git a/librpc/ndr/ndr_string.c b/librpc/ndr/ndr_string.c
index 0fefc887c30..3def351072c 100644
--- a/librpc/ndr/ndr_string.c
+++ b/librpc/ndr/ndr_string.c
@@ -553,6 +553,47 @@ _PUBLIC_ uint32_t ndr_string_length(const void *_var, uint32_t element_size)
 	return i+1;
 }
 
+/**
+ * @brief Get the string length including the null terminator if available.
+ *
+ * This checks the string length based on the elements. The returned number
+ * includes the terminating null byte(s) if found.
+ *
+ * @param[in]  _var    The string the calculate the length for.
+ *
+ * @param[in]  length  The length of the buffer passed by _var.
+ *
+ * @param[in]  element_size The element_size of a string char in bytes.
+ *
+ * @return The length of the strings or 0.
+ */
+static uint32_t ndr_string_n_length(const void *_var,
+				    size_t length,
+				    uint32_t element_size)
+{
+	size_t i = 0;
+	uint8_t zero[4] = {0,0,0,0};
+	const char *var = (const char *)_var;
+	int cmp;
+
+	if (element_size > 4) {
+		return 0;
+	}
+
+	for (i = 0; i < length; i++, var += element_size) {
+		cmp = memcmp(var, zero, element_size);
+		if (cmp == 0) {
+			break;
+		}
+	}
+
+	if (i == length) {
+		return length;
+	}
+
+	return i + 1;
+}
+
 _PUBLIC_ enum ndr_err_code ndr_check_string_terminator(struct ndr_pull *ndr, uint32_t count, uint32_t element_size)
 {
 	uint32_t i;
@@ -622,8 +663,12 @@ _PUBLIC_ enum ndr_err_code ndr_pull_charset_to_null(struct ndr_pull *ndr, int nd
 
 	NDR_PULL_NEED_BYTES(ndr, length*byte_mul);
 
-	str_len = ndr_string_length(ndr->data+ndr->offset, byte_mul);
-	str_len = MIN(str_len, length);	/* overrun protection */
+	str_len = ndr_string_n_length(ndr->data+ndr->offset, length, byte_mul);
+	if (str_len == 0) {
+		return ndr_pull_error(ndr, NDR_ERR_LENGTH,
+				      "Invalid length");
+	}
+
 	if (!convert_string_talloc(ndr->current_mem_ctx, chset, CH_UNIX,
 				   ndr->data+ndr->offset, str_len*byte_mul,
 				   discard_const_p(void *, var),
diff --git a/python/samba/provision/sambadns.py b/python/samba/provision/sambadns.py
index 9b245608c63..239c99ff0b9 100644
--- a/python/samba/provision/sambadns.py
+++ b/python/samba/provision/sambadns.py
@@ -858,9 +858,19 @@ def create_samdb_copy(samdb, logger, paths, names, domainsid, domainguid):
                 os.path.join(dns_samldb_dir, metadata_file))
         os.link(os.path.join(private_dir, domainzone_file),
                 os.path.join(dns_dir, domainzone_file))
+        if backend_store == "mdb":
+            # If the file is an lmdb data file need to link the
+            # lock file as well
+            os.link(os.path.join(private_dir, domainzone_file + "-lock"),
+                    os.path.join(dns_dir, domainzone_file + "-lock"))
         if forestzone_file:
             os.link(os.path.join(private_dir, forestzone_file),
                     os.path.join(dns_dir, forestzone_file))
+            if backend_store == "mdb":
+                # If the database file is an lmdb data file need to link the
+                # lock file as well
+                os.link(os.path.join(private_dir, forestzone_file + "-lock"),
+                        os.path.join(dns_dir, forestzone_file + "-lock"))
     except OSError:
         logger.error(
             "Failed to setup database for BIND, AD based DNS cannot be used")
diff --git a/python/samba/tests/samba_upgradedns_lmdb.py b/python/samba/tests/samba_upgradedns_lmdb.py
new file mode 100644
index 00000000000..048993152e2
--- /dev/null
+++ b/python/samba/tests/samba_upgradedns_lmdb.py
@@ -0,0 +1,75 @@
+# Unix SMB/CIFS implementation.
+# Copyright (C) Catalyst IT Ltd. 2019
+#
+# 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/>.
+#
+
+from samba.tests.samba_tool.base import SambaToolCmdTest
+import os
+import shutil
+
+
+class UpgradeDnsLmdbTestCase(SambaToolCmdTest):
+    """
+        Tests for dns upgrade on a lmdb backend
+    """
+
+    def setUp(self):
+        super(UpgradeDnsLmdbTestCase, self).setUp()
+        self.tempsambadir = os.path.join(self.tempdir, "samba")
+        os.mkdir(self.tempsambadir)
+
+    # provision a domain
+    #
+    # returns the tuple (ret, stdout, stderr)
+    def provision(self):
+        command = (
+            "samba-tool "
+            "domain provision "
+            "--realm=foo.example.com "
+            "--domain=FOO "
+            "--targetdir=%s "
+            "--backend-store=mdb "
+            "--use-ntvfs " % self.tempsambadir)
+        return self.run_command(command)
+
+    # upgrade a domains dns to BIND9
+    #
+    # returns the tuple (ret, stdout, stderr)
+    def upgrade_dns(self):
+        command = (
+            "samba_upgradedns "
+            "--dns-backend=BIND9_DLZ "
+            "--configfile %s/etc/smb.conf" % self.tempsambadir)
+        return self.run_command(command)
+
+    def tearDown(self):
+        super(UpgradeDnsLmdbTestCase, self).tearDown()
+        shutil.rmtree(self.tempsambadir)
+
+    def test_lmdb_lock_files_linked_on_upgrade_to_bind9_dlz(self):
+        """
+            Ensure that links are created for the lock files as well as the
+            data files
+        """
+        self.provision()
+        self.upgrade_dns()
+        directory = ("%s/bind-dns/dns/sam.ldb.d" % self.tempsambadir)
+        for filename in os.listdir(directory):
+            if filename.endswith(".ldb") and "DNSZONES" in filename:
+                lock_file = ("%s/%s-lock" % (directory, filename))
+                self.assertTrue(
+                    os.path.isfile(lock_file),
+                    msg=("Lock file %s/%s-lock for %s, does not exist" %
+                         (directory, filename, filename)))
diff --git a/source3/modules/vfs_ceph_snapshots.c b/source3/modules/vfs_ceph_snapshots.c
index 4d935a55a1a..0b5f7ab59a5 100644
--- a/source3/modules/vfs_ceph_snapshots.c
+++ b/source3/modules/vfs_ceph_snapshots.c
@@ -390,8 +390,12 @@ static int ceph_snap_get_shadow_copy_data(struct vfs_handle_struct *handle,
 		parent_dir = tmp;
 	}
 
-	ret = snprintf(snaps_path, sizeof(snaps_path), "%s/%s",
-		       parent_dir, snapdir);
+	if (strlen(parent_dir) == 0) {
+		ret = strlcpy(snaps_path, snapdir, sizeof(snaps_path));
+	} else {
+		ret = snprintf(snaps_path, sizeof(snaps_path), "%s/%s",
+			       parent_dir, snapdir);
+	}
 	if (ret >= sizeof(snaps_path)) {
 		ret = -EINVAL;
 		goto err_out;
@@ -534,7 +538,11 @@ static int ceph_snap_gmt_convert_dir(struct vfs_handle_struct *handle,
 	/*
 	 * Temporally use the caller's return buffer for this.
 	 */
-	ret = snprintf(_converted_buf, buflen, "%s/%s", name, snapdir);
+	if (strlen(name) == 0) {
+		ret = strlcpy(_converted_buf, snapdir, buflen);
+	} else {
+		ret = snprintf(_converted_buf, buflen, "%s/%s", name, snapdir);
+	}
 	if (ret >= buflen) {
 		ret = -EINVAL;
 		goto err_out;
diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py
index 2bc4561b87a..f8fb0074c02 100755
--- a/source4/selftest/tests.py
+++ b/source4/selftest/tests.py
@@ -700,6 +700,8 @@ planpythontestsuite("none", "samba.tests.samba_tool.help")
 planpythontestsuite("ad_dc_default:local", "samba.tests.samba_tool.passwordsettings")
 planpythontestsuite("ad_dc:local", "samba.tests.samba_tool.dsacl")
 
+planpythontestsuite("none", "samba.tests.samba_upgradedns_lmdb")
+
 # Run these against chgdcpass to share the runtime load
 planpythontestsuite("chgdcpass:local", "samba.tests.samba_tool.sites")
 planpythontestsuite("chgdcpass:local", "samba.tests.samba_tool.dnscmd")
diff --git a/source4/utils/oLschema2ldif/test.c b/source4/utils/oLschema2ldif/test.c
index 6748ce08c33..3834ea462fd 100644
--- a/source4/utils/oLschema2ldif/test.c
+++ b/source4/utils/oLschema2ldif/test.c
@@ -19,6 +19,7 @@
 
 #include <stdarg.h>
 #include <stddef.h>
+#include <stdint.h>
 #include <setjmp.h>
 #include <cmocka.h>
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list