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

Karolin Seeger kseeger at samba.org
Fri Jun 26 11:19:12 UTC 2020


The branch, v4-12-test has been updated
       via  50badbae62f s3: msdfs: Fix missing struct stat return on msdfs links by doing an LSTAT call.
       via  54d6efeb917 s3: torture: Add test for getting attibutes on an MSDFS link.
       via  68c0b008bdd s3: torture: Add a MSDFS-ATTRIBUTE test.
       via  50ff83cb3e3 s3: libsmb: Info level SMB_FIND_EA_SIZE encodes attibutes as a uint16, not a uint8.
       via  7db0eb75680 s3: libsmb: Info level SMB_FIND_INFO_STANDARD encodes attibutes as a uint16, not a uint8.
       via  bb210d6d29b s3: libsmb: Info level SMB_FIND_FILE_BOTH_DIRECTORY_INFO encodes attibutes as a uint32, not a uint8.
       via  10e8d8b4b13 s3: libsmb: Info level SMB2_FIND_ID_BOTH_DIRECTORY_INFO encodes attibutes as a uint32, not a uint8.
       via  1f8a77fe3aa s3: smbd: Allow a SHUTDOWN_CLOSE on a file with outstanding aio if there are no client connections alive.
       via  8666dc1eec6 s3: smbd: Add smbXsrv_client_valid_connections().
       via  19c6e21cfd6 s3: selftest: Add samba3.blackbox.aio-outstanding test.
      from  3db89a6c880 ldb_ldap: fix off-by-one increment in lldb_add_msg_attr

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


- Log -----------------------------------------------------------------
commit 50badbae62f51789a776cd3aa80a80d9aed1d8fe
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Jun 1 14:09:54 2020 -0700

    s3: msdfs: Fix missing struct stat return on msdfs links by doing an LSTAT call.
    
    This (unfortunately) re-exposes the fact the msdfs links are symlinks,
    bit fixing this correctly requires a VFS ABI change which we can't
    do for a released stream.
    
    Remove the knownfail.d/msdfs-attr file.
    
    Everything now passes.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14391
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(v4-12-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-12-test): Fri Jun 26 11:18:10 UTC 2020 on sn-devel-184

commit 54d6efeb917ba8e7a69ed4b0e9c94adad1545e5d
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Jun 1 13:45:28 2020 -0700

    s3: torture: Add test for getting attibutes on an MSDFS link.
    
    Mark as knownfail for now.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14391
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (back ported from commit 2a4705129d06b91023bc3fc435fccf91d3939553)

commit 68c0b008bddcb25e13184f3a6b67f09b1d08f5a7
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Jun 1 12:08:17 2020 -0700

    s3: torture: Add a MSDFS-ATTRIBUTE test.
    
    Framework to drive comes next.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14391
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 84134812e3447317125ae08b2a98848a2e4bbd65)

commit 50ff83cb3e3bc9247c639308057b7c927c266701
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Jun 1 11:33:13 2020 -0700

    s3: libsmb: Info level SMB_FIND_EA_SIZE encodes attibutes as a uint16, not a uint8.
    
    We will need this to detect FILE_ATTRIBUTE_REPARSE_POINT in a later commit.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14391
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 6463f2612a662f217af18455206afde122323375)

commit 7db0eb75680a8af464ad26122331e0b808bc5aa5
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Jun 1 12:01:13 2020 -0700

    s3: libsmb: Info level SMB_FIND_INFO_STANDARD encodes attibutes as a uint16, not a uint8.
    
    We will need this to detect FILE_ATTRIBUTE_REPARSE_POINT in a later commit.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14391
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit be52f87c376a8f71b2de4aa52f25818cad2b160e)

commit bb210d6d29bcd08a36334e9b159c0a5fd3d82bf5
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Jun 1 11:36:03 2020 -0700

    s3: libsmb: Info level SMB_FIND_FILE_BOTH_DIRECTORY_INFO encodes attibutes as a uint32, not a uint8.
    
    Cast to a uint16_t for now after pulling the information
    as finfo->mode is currently only 16 bits.
    
    We will need this to detect FILE_ATTRIBUTE_REPARSE_POINT in a later commit.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14391
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 5e3e6c4c0c70e171607f4b5351bd8ec146730f08)

commit 10e8d8b4b13a7d1bbd07072a8ebd178ca12b9641
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Jun 1 13:55:10 2020 -0700

    s3: libsmb: Info level SMB2_FIND_ID_BOTH_DIRECTORY_INFO encodes attibutes as a uint32, not a uint8.
    
    Fix the SMB2 parsing code.
    
    Cast to a uint16_t for now after pulling the information
    as finfo->mode is currently only 16 bits.
    
    We will need this to detect FILE_ATTRIBUTE_REPARSE_POINT in a later commit.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 3063e1601ad9e2536651a75a47ebf4921ffddbdc)

commit 1f8a77fe3aaebb15f3c71e6d3a46e2ef15590b29
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Jun 16 15:01:49 2020 -0700

    s3: smbd: Allow a SHUTDOWN_CLOSE on a file with outstanding aio if there are no client connections alive.
    
    The process is exiting now so pthreads will never complete to cause
    problems.
    
    Remove the knownfail.d/aio_outstanding entry.
    
    Followup-bugfix for:
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14301
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed Jun 24 20:14:15 UTC 2020 on sn-devel-184
    
    (cherry picked from commit 205653732064ecf76d3198451240af468806ec14)

commit 8666dc1eec63b74830b95112bb4c589c5aa788dd
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Jun 25 14:56:03 2020 -0700

    s3: smbd: Add smbXsrv_client_valid_connections().
    
    Next commit will make use of this.
    
    Followup-bugfix for:
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14301
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit 19c6e21cfd62dcda709fca5ea9fc1bad04533277
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Jun 22 13:44:12 2020 -0700

    s3: selftest: Add samba3.blackbox.aio-outstanding test.
    
    Shows smbd panics if connection is terminated (torn down)
    by killing the client with outstanding aio requests in the
    queue. As we're closing smbd we should cope with this.
    
    Followup-bugfix for:
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14301
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit f206d37f6ec8143b2051a8fe15783c188344adbe)

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

Summary of changes:
 source3/libsmb/cli_smb2_fnum.c                     |  3 +-
 source3/libsmb/clilist.c                           |  7 +-
 ...orce_close_share.sh => test_aio_outstanding.sh} | 64 ++++++++----------
 source3/selftest/tests.py                          | 35 ++++++++++
 source3/smbd/close.c                               | 26 +++++++
 source3/smbd/globals.h                             |  1 +
 source3/smbd/msdfs.c                               |  7 ++
 source3/smbd/smb2_server.c                         | 14 ++++
 source3/torture/torture.c                          | 79 ++++++++++++++++++++++
 9 files changed, 196 insertions(+), 40 deletions(-)
 copy source3/script/tests/{test_force_close_share.sh => test_aio_outstanding.sh} (50%)


Changeset truncated at 500 lines:

diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 8c8b33f49ed..4edeefc117d 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -1236,7 +1236,8 @@ static NTSTATUS parse_finfo_id_both_directory_info(uint8_t *dir_data,
 	finfo->ctime_ts = interpret_long_date((const char *)dir_data + 32);
 	finfo->size = IVAL2_TO_SMB_BIG_UINT(dir_data + 40, 0);
 	finfo->allocated_size = IVAL2_TO_SMB_BIG_UINT(dir_data + 48, 0);
-	finfo->mode = CVAL(dir_data + 56, 0);
+	/* NB. We need to enlarge finfo->mode to be 32-bits. */
+	finfo->mode = (uint16_t)IVAL(dir_data + 56, 0);
 	finfo->ino = IVAL2_TO_SMB_BIG_UINT(dir_data + 96, 0);
 	namelen = IVAL(dir_data + 60,0);
 	if (namelen > (dir_data_length - 104)) {
diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c
index f9444bc401c..4a32fc45fa6 100644
--- a/source3/libsmb/clilist.c
+++ b/source3/libsmb/clilist.c
@@ -152,7 +152,7 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx,
 			finfo->mtime_ts = convert_time_t_to_timespec(
 				make_unix_date2(p+12, smb1cli_conn_server_time_zone(cli->conn)));
 			finfo->size = IVAL(p,16);
-			finfo->mode = CVAL(p,24);
+			finfo->mode = SVAL(p,24);
 			len = CVAL(p, 26);
 			p += 27;
 			if (recv_flags2 & FLAGS2_UNICODE_STRINGS) {
@@ -211,7 +211,7 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx,
 			finfo->mtime_ts = convert_time_t_to_timespec(
 				make_unix_date2(p+12, smb1cli_conn_server_time_zone(cli->conn)));
 			finfo->size = IVAL(p,16);
-			finfo->mode = CVAL(p,24);
+			finfo->mode = SVAL(p,24);
 			len = CVAL(p, 30);
 			p += 31;
 			/* check for unisys! */
@@ -257,7 +257,8 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx,
 			finfo->size = IVAL2_TO_SMB_BIG_UINT(p,0);
 			p += 8;
 			p += 8; /* alloc size */
-			finfo->mode = CVAL(p,0);
+			/* NB. We need to enlarge finfo->mode to be 32-bits. */
+			finfo->mode = (uint16_t)IVAL(p,0);
 			p += 4;
 			namelen = IVAL(p,0);
 			p += 4;
diff --git a/source3/script/tests/test_force_close_share.sh b/source3/script/tests/test_aio_outstanding.sh
similarity index 50%
copy from source3/script/tests/test_force_close_share.sh
copy to source3/script/tests/test_aio_outstanding.sh
index da78b5a752e..b189343bb24 100755
--- a/source3/script/tests/test_force_close_share.sh
+++ b/source3/script/tests/test_aio_outstanding.sh
@@ -1,38 +1,39 @@
 #!/bin/bash
 #
-# Test smbcontrol close-share command.
-#
-# Copyright (C) 2020 Volker Lendecke
-# Copyright (C) 2020 Jeremy Allison
+# Test terminating an smbclient connection with outstanding
+# aio requests.
 #
 # Note this is designed to be run against
 # the aio_delay_inject share which is preconfigured
 # with 2 second delays on pread/pwrite.
 
-if [ $# -lt 5 ]; then
-    echo Usage: test_share_force_close.sh \
-	 SERVERCONFFILE SMBCLIENT SMBCONTROL IP aio_delay_inject_sharename
+if [ $# -lt 4 ]; then
+    echo Usage: test_aio_outstanding.sh \
+	 SERVERCONFFILE SMBCLIENT IP aio_delay_inject_sharename
 exit 1
 fi
 
 CONF=$1
 SMBCLIENT=$2
-SMBCONTROL=$3
-SERVER=$4
-SHARE=$5
+SERVER=$3
+SHARE=$4
 
 incdir=$(dirname $0)/../../../testprogs/blackbox
 . $incdir/subunit.sh
 
 failed=0
+#
+# Note if we already have any panics in the smbd log.
+#
+panic_count_0=$(grep -c PANIC $SMBD_TEST_LOG)
 
 # Create the smbclient communication pipes.
 rm -f smbclient-stdin smbclient-stdout smbclient-stderr
 mkfifo smbclient-stdin smbclient-stdout smbclient-stderr
 
 # Create a large-ish testfile
-rm testfile
-head -c 20MB /dev/zero >testfile
+rm aio_outstanding_testfile
+head -c 20MB /dev/zero >aio_outstanding_testfile
 
 CLI_FORCE_INTERACTIVE=1; export CLI_FORCE_INTERACTIVE
 
@@ -49,52 +50,43 @@ head -n 1 <&101
 head -n 1 <&102
 
 # Ensure we're putting a fresh file.
-echo "del testfile" >&100
-echo "put testfile" >&100
-
-sleep 1
+echo "del aio_outstanding_testfile" >&100
+echo "put aio_outstanding_testfile" >&100
 
-# Close the aio_delay_inject share whilst we have outstanding writes.
+sleep 2
 
-testit "smbcontrol" ${SMBCONTROL} ${CONF} smbd close-share ${SHARE} ||
-    failed=$(expr $failed + 1)
+# Terminate the smbclient write to the aio_delay_inject share whilst
+# we have outstanding writes.
+kill $CLIENT_PID
 
 sleep 1
 
-# If we get one or more NT_STATUS_NETWORK_NAME_DELETED
-# or NT_STATUS_INVALID_HANDLE on stderr from the writes we
-# know the server stayed up and didn't crash when the
-# close-share removed the share.
+# Ensure the panic count didn't change.
 #
 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=14301
 #
-COUNT=$(head -n 2 <&102 |
-	    grep -e NT_STATUS_NETWORK_NAME_DELETED -e NT_STATUS_INVALID_HANDLE |
-	    wc -l)
-
-testit "Verify close-share did cancel the file put" \
-       test $COUNT -ge 1 || failed=$(expr $failed + 1)
 
-kill ${CLIENT_PID}
+panic_count_1=$(grep -c PANIC $SMBD_TEST_LOG)
 
 # Rerun smbclient to remove the testfile on the server.
-rm -f smbclient-stdin smbclient-stdout smbclient-stderr testfile
+rm -f smbclient-stdin smbclient-stdout smbclient-stderr aio_outstanding_testfile
 mkfifo smbclient-stdin smbclient-stdout
 
 ${SMBCLIENT} //${SERVER}/${SHARE} ${CONF} -U${USER}%${PASSWORD} \
 	     < smbclient-stdin > smbclient-stdout &
-CLIENT_PID=$!
 
 sleep 1
 
 exec 100>smbclient-stdin  101<smbclient-stdout
 
-echo "del testfile" >&100
+echo "del aio_outstanding_testfile" >&100
+echo "exit" >&100
 
-sleep 1
+sleep 2
 
-kill ${CLIENT_PID}
+rm -f smbclient-stdin smbclient-stdout aio_outstanding_testfile
 
-rm -f smbclient-stdin smbclient-stdout testfile
+testit "check_panic" test $panic_count_0 -eq $panic_count_1 ||
+        failed=$(expr $failed + 1)
 
 testok $0 $failed
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 72bca263c0b..dc44160e50d 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -162,6 +162,33 @@ plantestsuite("samba3.smbtorture_s3.hidenewfiles(simpleserver)",
                "",
                "-l $LOCAL_PATH"])
 
+#
+# MSDFS attribute tests.
+#
+plantestsuite("samba3.smbtorture_s3.smb2.MSDFS-ATTRIBUTE",
+                "fileserver",
+                [os.path.join(samba3srcdir,
+                              "script/tests/test_smbtorture_s3.sh"),
+                'MSDFS-ATTRIBUTE',
+                '//$SERVER_IP/msdfs-share',
+                '$USERNAME',
+                '$PASSWORD',
+                smbtorture3,
+                "-mSMB2",
+                "-f msdfs-src1"])
+
+plantestsuite("samba3.smbtorture_s3.smb1.MSDFS-ATTRIBUTE",
+                "fileserver",
+                [os.path.join(samba3srcdir,
+                              "script/tests/test_smbtorture_s3.sh"),
+                'MSDFS-ATTRIBUTE',
+                '//$SERVER_IP/msdfs-share',
+                '$USERNAME',
+                '$PASSWORD',
+                smbtorture3,
+                "-mNT1",
+                "-f msdfs-src1"])
+
 shares = [
     "vfs_aio_pthread_async_dosmode_default1",
     "vfs_aio_pthread_async_dosmode_default2",
@@ -838,6 +865,14 @@ plantestsuite("samba3.blackbox.net_tdb", "simpleserver:local",
                smbclient3, '$SERVER', 'tmp', '$USERNAME', '$PASSWORD',
                configuration, '$LOCAL_PATH', '$LOCK_DIR'])
 
+plantestsuite("samba3.blackbox.aio-outstanding", "simpleserver:local",
+              [os.path.join(samba3srcdir,
+                            "script/tests/test_aio_outstanding.sh"),
+               configuration,
+               os.path.join(bindir(), "smbclient"),
+               '$SERVER_IP',
+               "aio_delay_inject"])
+
 plantestsuite("samba3.blackbox.smbd_error", "simpleserver:local",
               [os.path.join(samba3srcdir, "script/tests/test_smbd_error.sh")])
 
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index d5af62a277c..1a6e33b4403 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -639,12 +639,38 @@ static NTSTATUS ntstatus_keeperror(NTSTATUS s1, NTSTATUS s2)
 static void assert_no_pending_aio(struct files_struct *fsp,
 				  enum file_close_type close_type)
 {
+	struct smbXsrv_client *client = global_smbXsrv_client;
+	size_t num_connections_alive;
 	unsigned num_requests = fsp->num_aio_requests;
 
 	if (num_requests == 0) {
 		return;
 	}
 
+	num_connections_alive = smbXsrv_client_valid_connections(client);
+
+	if (close_type == SHUTDOWN_CLOSE && num_connections_alive == 0) {
+		/*
+		 * fsp->aio_requests and the contents (fsp->aio_requests[x])
+		 * are both independently owned by fsp and are not in a
+		 * talloc heirarchy. This allows the fsp->aio_requests array to
+		 * be reallocated independently of the array contents so it can
+		 * grow on demand.
+		 *
+		 * This means we must ensure order of deallocation
+		 * on a SHUTDOWN_CLOSE by deallocating the fsp->aio_requests[x]
+		 * contents first, as their destructors access the
+		 * fsp->aio_request array. If we don't deallocate them
+		 * first, when fsp is deallocated fsp->aio_requests
+		 * could have been deallocated *before* its contents
+		 * fsp->aio_requests[x], causing a crash.
+		 */
+		while (fsp->num_aio_requests != 0) {
+			TALLOC_FREE(fsp->aio_requests[0]);
+		}
+		return;
+	}
+
 	DBG_ERR("fsp->num_aio_requests=%u\n", num_requests);
 	smb_panic("can not close with outstanding aio requests");
 	return;
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index 7b26d04ed0f..5bcf0503b4c 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -219,6 +219,7 @@ NTSTATUS smbd_calculate_access_mask(connection_struct *conn,
 
 void smbd_notify_cancel_by_smbreq(const struct smb_request *smbreq);
 
+size_t smbXsrv_client_valid_connections(struct smbXsrv_client *client);
 void smbd_server_connection_terminate_ex(struct smbXsrv_connection *xconn,
 					 const char *reason,
 					 const char *location);
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index cc32ebc9d29..c57866f7939 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -633,6 +633,13 @@ bool is_msdfs_link(connection_struct *conn,
 					smb_fname,
 					NULL,
 					NULL);
+	if (NT_STATUS_IS_OK(status)) {
+		int ret;
+		ret = SMB_VFS_LSTAT(conn, smb_fname);
+		if (ret < 0) {
+			status = map_nt_error_from_unix(errno);
+		}
+	}
 	return (NT_STATUS_IS_OK(status));
 }
 
diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c
index 88937ac19b0..f0fe14624cd 100644
--- a/source3/smbd/smb2_server.c
+++ b/source3/smbd/smb2_server.c
@@ -1106,6 +1106,20 @@ static NTSTATUS smbd_smb2_request_setup_out(struct smbd_smb2_request *req)
 	return NT_STATUS_OK;
 }
 
+size_t smbXsrv_client_valid_connections(struct smbXsrv_client *client)
+{
+	struct smbXsrv_connection *xconn = NULL;
+	size_t num_ok = 0;
+
+	for (xconn = client->connections; xconn != NULL; xconn = xconn->next) {
+		if (NT_STATUS_IS_OK(xconn->transport.status)) {
+			num_ok++;
+		}
+	}
+
+	return num_ok;
+}
+
 void smbd_server_connection_terminate_ex(struct smbXsrv_connection *xconn,
 					 const char *reason,
 					 const char *location)
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index f07a0adf115..56258d3d2ad 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -11405,6 +11405,81 @@ static bool run_large_readx(int dummy)
 	return correct;
 }
 
+static NTSTATUS msdfs_attribute_list_fn(const char *mnt,
+				  struct file_info *finfo,
+				  const char *mask,
+				  void *private_data)
+{
+	uint16_t *p_mode = (uint16_t *)private_data;
+
+	if (strequal(finfo->name, test_filename)) {
+		*p_mode = finfo->mode;
+	}
+
+	return NT_STATUS_OK;
+}
+
+static bool run_msdfs_attribute(int dummy)
+{
+	static struct cli_state *cli;
+	bool correct = false;
+	uint16_t mode = 0;
+	NTSTATUS status;
+
+	printf("Starting MSDFS-ATTRIBUTE test\n");
+
+	if (test_filename == NULL || test_filename[0] == '\0') {
+		printf("MSDFS-ATTRIBUTE test "
+			"needs -f filename-of-msdfs-link\n");
+		return false;
+	}
+
+	/*
+	 * NB. We use torture_open_connection_flags() not
+	 * torture_open_connection() as the latter forces
+	 * SMB1.
+	 */
+	if (!torture_open_connection_flags(&cli, 0, 0)) {
+		return false;
+	}
+
+	smbXcli_conn_set_sockopt(cli->conn, sockops);
+
+	status = cli_list(cli,
+			"*",
+			FILE_ATTRIBUTE_DIRECTORY,
+			msdfs_attribute_list_fn,
+			&mode);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("cli_list failed with %s\n",
+			nt_errstr(status));
+		goto out;
+	}
+	if ((mode & FILE_ATTRIBUTE_REPARSE_POINT) == 0) {
+		printf("file %s should have "
+			"FILE_ATTRIBUTE_REPARSE_POINT set. attr = 0x%x\n",
+			test_filename,
+			(unsigned int)mode);
+		goto out;
+	}
+
+	if ((mode & FILE_ATTRIBUTE_DIRECTORY) == 0) {
+		printf("file %s should have "
+			"FILE_ATTRIBUTE_DIRECTORY set. attr = 0x%x\n",
+			test_filename,
+			(unsigned int)mode);
+		goto out;
+	}
+
+	correct = true;
+
+  out:
+
+	torture_close_connection(cli);
+	return correct;
+}
+
 static bool run_cli_echo(int dummy)
 {
 	struct cli_state *cli;
@@ -14539,6 +14614,10 @@ static struct {
 		.name  = "LARGE_READX",
 		.fn    = run_large_readx,
 	},
+	{
+		.name  = "MSDFS-ATTRIBUTE",
+		.fn    = run_msdfs_attribute,
+	},
 	{
 		.name  = "NTTRANS-CREATE",
 		.fn    = run_nttrans_create,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list