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

Karolin Seeger kseeger at samba.org
Tue Jan 14 12:47:04 UTC 2020


The branch, v4-10-test has been updated
       via  b2800628a6b ctdb-tests: Skip some tests that don't work with IPv6
       via  57390cc5a36 ctdb-scripts: Strip square brackets when gathering connection info
       via  6a109e3ddb3 librpc: Fix string length checking in ndr_pull_charset_to_null()
       via  fe015ece4ee upgradedns: ensure lmdb lock files linked
       via  78fb3cb0051 test upgradedns: ensure lmdb lock files linked
       via  decce5e6e19 docs-xml/winbindnssinfo: clarify interaction with idmap_ad etc.
       via  a2f8fdb4109 libsmbclient: If over SMB1 first try to do a posix stat on the file.
       via  6ae62c26ef9 s3:libsmb: Add a setup_stat_from_stat_ex() function
       via  0d32af6001d s3:libsmb: Return a 'struct stat' buffer for SMBC_getatr()
       via  9c7ec52a017 s3:libsmb: Add try_posixinfo to SMBSRV struct. Only enable for SMB1 with UNIX for now.
       via  9cb73280894 s3:libsmb: Generate the inode only based on the path component
       via  745f563d4c7 s3: libsmb: Move setting all struct stat fields into setup_stat().
       via  ee236c2f307 s3: libsmb: Move setting st->st_ino into setup_stat.
       via  06b0e8d3ae1 s3: libsmb: Change generate_inode()/setup_stat() to modern coding standards.
      from  b5e8ba021bf s3: VFS: glusterfs: Reset nlinks for symlink entries during readdir

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


- Log -----------------------------------------------------------------
commit b2800628a6b0494d0e7c82a89ae288fdd0ae36f5
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-10-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-10-test): Tue Jan 14 12:46:17 UTC 2020 on sn-devel-144

commit 57390cc5a367376917f2c9a4545098742f7baccc
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 6a109e3ddb355ec91e136f8b8dfbd29631ce25e8
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 fe015ece4ee1b61efb97319156bfa85f299e8ffb
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 78fb3cb005154482748c529e0c8dc47b7563504d
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.
    
    Changes to python/samba/tests/__init__.py adding run_command manually
    copied from commit b27817d491794a292278832e3f59f955f418a6cb
    
    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 decce5e6e194308933a23a524de530a9bc30a5cc
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)

commit a2f8fdb410959f1c2cfa87ac7980d721674635dd
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Nov 25 11:11:13 2019 +0100

    libsmbclient: If over SMB1 first try to do a posix stat on the file.
    
    Disable in future, if server doesn't support this.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14101
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Thu Dec 19 15:44:25 UTC 2019 on sn-devel-184
    
    (cherry picked from commit 8b04590e4d8f817ad6d194bb9d622c18734e3011)

commit 6ae62c26ef9e358ed117893f4e0ce719049bb745
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Nov 25 11:10:49 2019 +0100

    s3:libsmb: Add a setup_stat_from_stat_ex() function
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14101
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit b3e3cb3bbd86a53b48ee009adf811d48dd50dc8b)

commit 0d32af6001d3d0d329b87da067c4e211b7c28577
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Nov 25 11:09:52 2019 +0100

    s3:libsmb: Return a 'struct stat' buffer for SMBC_getatr()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14101
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 0fe9dc5219beaf605da9c7922053f7324507b50e)

commit 9c7ec52a01709ea2c73313047f15c3ba6baf9595
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Nov 25 11:06:57 2019 +0100

    s3:libsmb: Add try_posixinfo to SMBSRV struct. Only enable for SMB1 with UNIX for now.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14101
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit bf9a3a7aa1913238ae2c997ce00369d0dbae3a08)

commit 9cb732808943f32049c46c0331fdd17d06a11e78
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Dec 18 13:27:26 2019 +0100

    s3:libsmb: Generate the inode only based on the path component
    
    Currently we use the full smb url which includes also username and
    password.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14101
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit ea51a426e506bd6456814ecddcb63441859f9d89)

commit 745f563d4c79d228c3780f187dd847c0c4d67b6e
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Oct 18 10:48:55 2019 -0700

    s3: libsmb: Move setting all struct stat fields into setup_stat().
    
    That way we only have one place where a struct stat is synthesised
    for libsmbclient callers.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 1f0715c0e5e6ff371e3b393a0b35222c8b6f49bc)

commit ee236c2f3078348bcc2bcfd5e4100be9711f6071
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Oct 18 09:34:02 2019 -0700

    s3: libsmb: Move setting st->st_ino into setup_stat.
    
    Signed-off-by: Puran Chand <pchand at vmware.com>
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 7d3b4f47be0359b496087fc40f89b815c7958dd6)

commit 06b0e8d3ae18ca64ee390ad638d77502a4efe8fa
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Oct 18 09:24:38 2019 -0700

    s3: libsmb: Change generate_inode()/setup_stat() to modern coding standards.
    
    Change setup_stat() to be void. It doesn't return anything. Export
    so it can be used by upcoming smbc_readdirplus2() call.
    
    Remove unused SMBCCTX *context parameters.
    Remove unused talloc_stackframe().
    
    Signed-off-by: Puran Chand <pchand at vmware.com>
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit d44a84295b46cc6c540a9730a615a59c1f22a277)

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

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 +-
 librpc/ndr/ndr_string.c                        |  49 ++++++++-
 python/samba/provision/sambadns.py             |  10 ++
 python/samba/tests/__init__.py                 |  16 +++
 python/samba/tests/samba_upgradedns_lmdb.py    |  75 ++++++++++++++
 source3/include/libsmb_internal.h              |  22 +++--
 source3/libsmb/libsmb_dir.c                    |  31 +++---
 source3/libsmb/libsmb_file.c                   | 122 ++++++++++++++---------
 source3/libsmb/libsmb_server.c                 |   9 ++
 source3/libsmb/libsmb_stat.c                   | 132 +++++++++++++++----------
 source3/libsmb/libsmb_xattr.c                  |  69 +++++--------
 source4/selftest/tests.py                      |   2 +
 15 files changed, 400 insertions(+), 176 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/librpc/ndr/ndr_string.c b/librpc/ndr/ndr_string.c
index cc3508616bb..7130726e341 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/__init__.py b/python/samba/tests/__init__.py
index 15824bd410a..ef0fdabbfa2 100644
--- a/python/samba/tests/__init__.py
+++ b/python/samba/tests/__init__.py
@@ -447,6 +447,22 @@ class BlackboxTestCase(TestCaseInTempDir):
         if retcode:
             raise BlackboxProcessError(retcode, line, stdoutdata, stderrdata)
         return stdoutdata
+    #
+    # Run a command without checking the return code, returns the tuple
+    # (ret, stdout, stderr)
+    # where ret is the return code
+    #       stdout is a string containing the commands stdout
+    #       stderr is a string containing the commands stderr
+    def run_command(self, line):
+        line = self._make_cmdline(line)
+        use_shell = not isinstance(line, list)
+        p = subprocess.Popen(line,
+                             stdout=subprocess.PIPE,
+                             stderr=subprocess.PIPE,
+                             shell=use_shell)
+        stdoutdata, stderrdata = p.communicate()
+        retcode = p.returncode
+        return (retcode, stdoutdata.decode('UTF8'), stderrdata.decode('UTF8'))
 
     # Generate a random password that can be safely  passed on the command line
     # i.e. it does not contain any shell meta characters.
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/include/libsmb_internal.h b/source3/include/libsmb_internal.h
index f3e44e875d8..af56df58792 100644
--- a/source3/include/libsmb_internal.h
+++ b/source3/include/libsmb_internal.h
@@ -76,6 +76,7 @@ typedef struct DOS_ATTR_DESC {
 struct _SMBCSRV {
 	struct cli_state *cli;
 	dev_t dev;
+	bool try_posixinfo;
 	bool no_pathinfo;
 	bool no_pathinfo2;
 	bool no_pathinfo3;
@@ -401,13 +402,7 @@ bool
 SMBC_getatr(SMBCCTX * context,
             SMBCSRV *srv,
             const char *path,
-            uint16_t *mode,
-            off_t *size,
-            struct timespec *create_time_ts,
-            struct timespec *access_time_ts,
-            struct timespec *write_time_ts,
-            struct timespec *change_time_ts,
-            SMB_INO_T *ino);
+	    struct stat *sbuf);
 
 bool
 SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path,
@@ -522,6 +517,19 @@ SMBC_attr_server(TALLOC_CTX *ctx,
 
 
 /* Functions in libsmb_stat.c */
+void setup_stat(struct stat *st,
+		const char *fname,
+		off_t size,
+		int mode,
+		ino_t ino,
+		dev_t dev,
+		struct timespec access_time_ts,
+		struct timespec change_time_ts,
+		struct timespec write_time_ts);
+void setup_stat_from_stat_ex(const struct stat_ex *stex,
+			     const char *fname,
+			     struct stat *st);
+
 int
 SMBC_stat_ctx(SMBCCTX *context,
               const char *fname,
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index 14bfcdec6a7..fd42c71b2b8 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -474,7 +474,6 @@ SMBC_opendir_ctx(SMBCCTX *context,
 	char *workgroup = NULL;
 	char *path = NULL;
 	size_t path_len = 0;
-        uint16_t mode;
 	uint16_t port = 0;
 	SMBCSRV *srv  = NULL;
 	SMBCFILE *dir = NULL;
@@ -961,6 +960,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
 				saved_errno = SMBC_errno(context, targetcli);
 
                                 if (saved_errno == EINVAL) {
+					struct stat sb = {0};
                                         /*
                                          * See if they asked to opendir
                                          * something other than a directory.
@@ -970,11 +970,11 @@ SMBC_opendir_ctx(SMBCCTX *context,
                                          */
                                         path[path_len] = '\0'; /* restore original path */
 
-                                        if (SMBC_getatr(context, srv, path,
-                                                        &mode, NULL,
-                                                        NULL, NULL, NULL, NULL,
-                                                        NULL) &&
-                                            ! IS_DOS_DIR(mode)) {
+                                        if (SMBC_getatr(context,
+							srv,
+							path,
+							&sb) &&
+                                            !S_ISDIR(sb.st_mode)) {
 
                                                 /* It is.  Correct the error value */
                                                 saved_errno = ENOTDIR;
@@ -2098,20 +2098,11 @@ SMBC_unlink_ctx(SMBCCTX *context,
 		if (errno == EACCES) { /* Check if the file is a directory */
 
 			int saverr = errno;
-			off_t size = 0;
-			uint16_t mode = 0;
-			struct timespec write_time_ts;
-                        struct timespec access_time_ts;
-                        struct timespec change_time_ts;
-			SMB_INO_T ino = 0;
-
-			if (!SMBC_getatr(context, srv, path, &mode, &size,
-					 NULL,
-                                         &access_time_ts,
-                                         &write_time_ts,
-                                         &change_time_ts,
-                                         &ino)) {
+			struct stat sb = {0};
+			bool ok;
 
+			ok = SMBC_getatr(context, srv, path, &sb);
+			if (!ok) {
 				/* Hmmm, bad error ... What? */
 
 				errno = SMBC_errno(context, targetcli);
@@ -2121,7 +2112,7 @@ SMBC_unlink_ctx(SMBCCTX *context,
 			}
 			else {
 
-				if (IS_DOS_DIR(mode))
+				if (S_ISDIR(sb.st_mode))
 					errno = EISDIR;
 				else
 					errno = saverr;  /* Restore this */
diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c
index ebd0bfe422a..140574e4cb8 100644
--- a/source3/libsmb/libsmb_file.c
+++ b/source3/libsmb/libsmb_file.c
@@ -452,18 +452,19 @@ bool
 SMBC_getatr(SMBCCTX * context,
             SMBCSRV *srv,
             const char *path,
-            uint16_t *mode,
-            off_t *size,
-            struct timespec *create_time_ts,
-            struct timespec *access_time_ts,
-            struct timespec *write_time_ts,
-            struct timespec *change_time_ts,
-            SMB_INO_T *ino)
+	    struct stat *sb)
 {
 	char *fixedpath = NULL;
 	char *targetpath = NULL;
 	struct cli_state *targetcli = NULL;
-	time_t write_time;
+	uint16_t mode = 0;
+	off_t size = 0;
+	struct timespec create_time_ts = {0};
+	struct timespec access_time_ts = {0};
+	struct timespec write_time_ts = {0};
+	struct timespec change_time_ts = {0};
+	time_t write_time = 0;
+	SMB_INO_T ino = 0;
 	TALLOC_CTX *frame = talloc_stackframe();
 	NTSTATUS status;
 
@@ -503,28 +504,56 @@ SMBC_getatr(SMBCCTX * context,
 		return False;
 	}
 
-	if (!srv->no_pathinfo2 &&
-            NT_STATUS_IS_OK(cli_qpathinfo2(targetcli, targetpath,
-                           create_time_ts,
-                           access_time_ts,
-                           write_time_ts,
-                           change_time_ts,
-			   size, mode, ino))) {
-		TALLOC_FREE(frame);
-		return True;
+	if (srv->try_posixinfo) {
+		SMB_STRUCT_STAT sbuf;
+
+		status = cli_posix_stat(targetcli, frame, &sbuf);
+		if (NT_STATUS_IS_OK(status)) {
+			setup_stat_from_stat_ex(&sbuf, path, sb);
+
+			TALLOC_FREE(frame);
+			return true;
+		}
+		if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED) ||
+		    NT_STATUS_EQUAL(status, NT_STATUS_INVALID_LEVEL)) {
+			/*
+			 * Turn this off if the server doesn't
+			 * support it.
+			 */
+			srv->try_posixinfo = false;
+		}
+	}
+
+	if (!srv->no_pathinfo2) {
+		status = cli_qpathinfo2(targetcli,
+					targetpath,
+					&create_time_ts,
+					&access_time_ts,
+					&write_time_ts,
+					&change_time_ts,
+					&size,
+					&mode,
+					&ino);
+		if (NT_STATUS_IS_OK(status)) {
+			goto setup_stat;
+		}
         }
 
 	srv->no_pathinfo2 = True;
 
-	if (!srv->no_pathinfo3 &&
-            NT_STATUS_IS_OK(cli_qpathinfo3(targetcli, targetpath,
-                           create_time_ts,
-                           access_time_ts,
-                           write_time_ts,
-                           change_time_ts,
-			   size, mode, ino))) {
-		TALLOC_FREE(frame);
-		return True;
+	if (!srv->no_pathinfo3) {
+		status = cli_qpathinfo3(targetcli,
+					targetpath,
+					&create_time_ts,
+					&access_time_ts,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list