[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Wed Sep 14 18:38:01 UTC 2022


The branch, master has been updated
       via  95bd776d2a3 s3: smbtorture3: Add test_smb1_qpathinfo() DFS test to run_smb1_dfs_operations().
       via  85dc30f9598 s3: smbtorture3: Add test_smb1_ctemp() DFS test to run_smb1_dfs_operations().
       via  7b5955dcd5a s3: smbtorture3: Add test_smb1_chkpath() DFS test to run_smb1_dfs_operations().
       via  5cbb8abc1b0 s3: smbtorture3: Add test_smb1_setatr() DFS test to run_smb1_dfs_operations().
       via  243433bd57a s3: smbtorture3: Add test_smb1_getatr() DFS test to run_smb1_dfs_operations().
       via  cc3d76d877b s3: smbtorture3: Add test_smb1_create() DFS test to run_smb1_dfs_operations().
       via  f1475e64b07 s3: smbtorture3: Add test_smb1_open() DFS test to run_smb1_dfs_operations().
       via  ad472f7741a s3: smbtorture3: Add test_smb1_openx() DFS test to run_smb1_dfs_operations().
       via  4e8e78e2345 s3: smbtorture3: Add test_smb1_nttrans_create() DFS test to run_smb1_dfs_operations().
       via  18bdcd85e4b s3: smbtorture3: Add test_smb1_ntcreatex() DFS test to run_smb1_dfs_operations().
       via  f7b06ea37c6 s3: smbtorture3: Add test_smb1_rmdir() DFS test to run_smb1_dfs_operations().
       via  2eb561f0a7c s3: smbtorture3: Add test_smb1_mkdir() DFS test to run_smb1_dfs_operations().
       via  ddc88e5c5ab s3: smbtorture3: Add an SMB1 operations torture tester.
       via  84e44cff39b s3: smbtorture3: Add a new test SMB2-NON-DFS-SHARE.
      from  8ae0c38d54f CVE-2021-20251 s3: Ensure bad password count atomic updates for SAMR AES password change

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


- Log -----------------------------------------------------------------
commit 95bd776d2a3167467f5ad9249049d982848886e3
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Sep 9 09:35:38 2022 -0700

    s3: smbtorture3: Add test_smb1_qpathinfo() DFS test to run_smb1_dfs_operations().
    
    Passes against Windows.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed Sep 14 18:37:06 UTC 2022 on sn-devel-184

commit 85dc30f95982cbb24620c11bf78c96417c70ca7a
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Sep 8 14:24:38 2022 -0700

    s3: smbtorture3: Add test_smb1_ctemp() DFS test to run_smb1_dfs_operations().
    
    NB. This passes against Windows, but SMBctemp is broken on a Windows DFS
    share and always returns NT_STATUS_FILE_IS_A_DIRECTORY.
    
    When we fix the Samba server to correctly process DFS
    pathnames we'll have to change this test to understand
    it's running against smbd and modify the expected behavior
    to match a working server.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>

commit 7b5955dcd5a8452fc6be8b251f44d9f236bb3eff
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Sep 8 12:23:23 2022 -0700

    s3: smbtorture3: Add test_smb1_chkpath() DFS test to run_smb1_dfs_operations().
    
    Passes against Windows.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Signed-off--by: Noel Power <npower at samba.org>

commit 5cbb8abc1b0ade63a80a1e77969c1d0b67ad5506
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Sep 8 11:45:54 2022 -0700

    s3: smbtorture3: Add test_smb1_setatr() DFS test to run_smb1_dfs_operations().
    
    Passes against Windows.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>

commit 243433bd57aeceb6c37a26dc62bb7bce8f6dac19
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Sep 7 16:04:03 2022 -0700

    s3: smbtorture3: Add test_smb1_getatr() DFS test to run_smb1_dfs_operations().
    
    Passes against Windows.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>

commit cc3d76d877b395a25266476fd29266641fe077c7
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Sep 7 15:42:09 2022 -0700

    s3: smbtorture3: Add test_smb1_create() DFS test to run_smb1_dfs_operations().
    
    Tests SMBcreate and SMBmknew.
    
    Passes against Windows.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>

commit f1475e64b07d7864c6465e9ada72a218a81eeb86
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Sep 7 15:26:55 2022 -0700

    s3: smbtorture3: Add test_smb1_open() DFS test to run_smb1_dfs_operations().
    
    Passes against Windows.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>

commit ad472f7741adeb8c1210d63dc20cba954cf5649d
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Sep 7 12:48:53 2022 -0700

    s3: smbtorture3: Add test_smb1_openx() DFS test to run_smb1_dfs_operations().
    
    Passes against Windows.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>

commit 4e8e78e2345c1de4955039809487492ded4d737f
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Sep 7 12:03:08 2022 -0700

    s3: smbtorture3: Add test_smb1_nttrans_create() DFS test to run_smb1_dfs_operations().
    
    Passes against Windows.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>

commit 18bdcd85e4b24647d1225b79ff7f9607e753df2e
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Sep 7 11:23:45 2022 -0700

    s3: smbtorture3: Add test_smb1_ntcreatex() DFS test to run_smb1_dfs_operations().
    
    Passes against Windows.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit f7b06ea37c6aba15a62a905192a46fcc5211871a
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Sep 7 10:41:53 2022 -0700

    s3: smbtorture3: Add test_smb1_rmdir() DFS test to run_smb1_dfs_operations().
    
    Passes against Windows.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>

commit 2eb561f0a7c1340227c7197946c7d4524c2e6b43
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Sep 6 17:49:05 2022 -0700

    s3: smbtorture3: Add test_smb1_mkdir() DFS test to run_smb1_dfs_operations().
    
    Passes against Windows.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>

commit ddc88e5c5ab4e62869816e38ea619e9f48fd46f4
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Sep 6 17:25:18 2022 -0700

    s3: smbtorture3: Add an SMB1 operations torture tester.
    
    Only tests SMB1unlink for now, but I will add other operations
    later.
    
    smbtorture3 test is: SMB1-DFS-OPERATIONS.
    
    Passes fully against Windows. Adds knownfail for smbd.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>

commit 84e44cff39b58985f53d6440c508abb7dfb41fd7
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Sep 8 16:42:26 2022 -0700

    s3: smbtorture3: Add a new test SMB2-NON-DFS-SHARE.
    
    This one is tricky. It sends SMB2 DFS pathnames to a non-DFS
    share, and sets the SMB2 flag FLAGS2_DFS_PATHNAMES in the SMB2
    packet.
    
    Windows will have non of it and (correctly) treats the pathnames
    as local paths (they're going to a non-DFS share). Samba fails.
    
    This proves the server looks as the share DFS capability to
    override the flag in the SMB2 packet.
    
    Passes against Windows. Added knownfail for Samba.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Noel Power <npower at samba.org>

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

Summary of changes:
 selftest/knownfail.d/dfs_paths  |    2 +
 selftest/target/Samba3.pm       |    7 +
 source3/selftest/tests.py       |   34 +
 source3/torture/proto.h         |    2 +
 source3/torture/test_smb1_dfs.c | 1869 +++++++++++++++++++++++++++++++++++++++
 source3/torture/test_smb2.c     |  162 ++++
 source3/torture/torture.c       |    8 +
 7 files changed, 2084 insertions(+)


Changeset truncated at 500 lines:

diff --git a/selftest/knownfail.d/dfs_paths b/selftest/knownfail.d/dfs_paths
index ed86a438736..64ddfc9160a 100644
--- a/selftest/knownfail.d/dfs_paths
+++ b/selftest/knownfail.d/dfs_paths
@@ -1,3 +1,5 @@
 ^samba3.smbtorture_s3.smb2.SMB2-DFS-PATHS.smbtorture\(fileserver\)
+^samba3.smbtorture_s3.smb2.SMB2-NON-DFS-SHARE.smbtorture\(fileserver\)
 ^samba3.smbtorture_s3.smb1.SMB1-DFS-PATHS.smbtorture\(fileserver\)
 ^samba3.smbtorture_s3.smb1.SMB1-DFS-SEARCH-PATHS.smbtorture\(fileserver\)
+^samba3.smbtorture_s3.smb1.SMB1-DFS-OPERATIONS.smbtorture\(fileserver\)
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 7c7735f6f4d..800df1f81bd 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -2537,6 +2537,9 @@ sub provision($$)
 	my $msdfs_pathname_share="$shrdir/msdfs_pathname_share";
 	push(@dirs,$msdfs_pathname_share);
 
+	my $non_msdfs_pathname_share="$shrdir/non_msdfs_pathname_share";
+	push(@dirs,$non_msdfs_pathname_share);
+
 	my $msdfs_deeppath="$msdfs_shrdir/deeppath";
 	push(@dirs,$msdfs_deeppath);
 
@@ -2968,6 +2971,10 @@ sub provision($$)
 	path = $msdfs_pathname_share
 	msdfs root = yes
 	guest ok = yes
+[non-msdfs-pathname-share]
+	path = $non_msdfs_pathname_share
+	msdfs root = no
+	guest ok = yes
 [hideunread]
 	copy = tmp
 	hide unreadable = yes
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 4b192cf4ad5..68959ba0b90 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -246,6 +246,24 @@ plantestsuite("samba3.smbtorture_s3.smb2.SMB2-DFS-PATHS",
                 smbtorture3,
                 "-mSMB2"])
 
+#
+# SMB2-NON-DFS-SHARE needs to run against a special share non-msdfs-pathname-share
+# This is an empty non-DFS share with no links, used merely to test
+# incoming DFS pathnames and how they map to local paths. We are testing
+# what happens if we set the FLAGS2_DFS_PATHNAMES and send DFS paths
+# on a non-DFS share.
+#
+plantestsuite("samba3.smbtorture_s3.smb2.SMB2-NON-DFS-SHARE",
+                "fileserver",
+                [os.path.join(samba3srcdir,
+                              "script/tests/test_smbtorture_s3.sh"),
+                'SMB2-NON-DFS-SHARE',
+                '//$SERVER_IP/non-msdfs-pathname-share',
+                '$USERNAME',
+                '$PASSWORD',
+                smbtorture3,
+                "-mSMB2"])
+
 #
 # SMB1-DFS-PATHS needs to run against a special share msdfs-pathname-share
 # This is an empty DFS share with no links, used merely to test
@@ -278,6 +296,22 @@ plantestsuite("samba3.smbtorture_s3.smb1.SMB1-DFS-SEARCH-PATHS",
                 smbtorture3,
                 "-mNT1"])
 
+#
+# SMB1-DFS-OPERATIONS needs to run against a special share msdfs-pathname-share
+# This is an empty DFS share with no links, used merely to test
+# incoming DFS pathnames and how they map to local paths.
+#
+plantestsuite("samba3.smbtorture_s3.smb1.SMB1-DFS-OPERATIONS",
+                "fileserver",
+                [os.path.join(samba3srcdir,
+                              "script/tests/test_smbtorture_s3.sh"),
+                'SMB1-DFS-OPERATIONS',
+                '//$SERVER_IP/msdfs-pathname-share',
+                '$USERNAME',
+                '$PASSWORD',
+                smbtorture3,
+                "-mNT1"])
+
 #
 # SMB2-STREAM-ACL needs to run against a special share - vfs_wo_fruit
 #
diff --git a/source3/torture/proto.h b/source3/torture/proto.h
index 873543d748c..7093e8a7665 100644
--- a/source3/torture/proto.h
+++ b/source3/torture/proto.h
@@ -121,8 +121,10 @@ bool run_smb2_sacl(int dummy);
 bool run_smb2_quota1(int dummy);
 bool run_smb2_stream_acl(int dummy);
 bool run_smb2_dfs_paths(int dummy);
+bool run_smb2_non_dfs_share(int dummy);
 bool run_smb1_dfs_paths(int dummy);
 bool run_smb1_dfs_search_paths(int dummy);
+bool run_smb1_dfs_operations(int dummy);
 bool run_list_dir_async_test(int dummy);
 bool run_delete_on_close_non_empty(int dummy);
 bool run_delete_on_close_nonwrite_delete_yes_test(int dummy);
diff --git a/source3/torture/test_smb1_dfs.c b/source3/torture/test_smb1_dfs.c
index 1acea318e37..5dfa7b41b6e 100644
--- a/source3/torture/test_smb1_dfs.c
+++ b/source3/torture/test_smb1_dfs.c
@@ -2361,3 +2361,1872 @@ bool run_smb1_dfs_search_paths(int dummy)
 	(void)smb1_dfs_delete(cli, "BAD\\BAD\\file");
 	return retval;
 }
+
+static bool smb1_create_testfile(struct cli_state *cli,
+				 const char *path)
+{
+	NTSTATUS status;
+	uint16_t fnum = (uint16_t)-1;
+
+	/* Create a test file. */
+	status = smb1cli_ntcreatex(cli->conn,
+				   cli->timeout,
+				   cli->smb1.pid,
+				   cli->smb1.tcon,
+				   cli->smb1.session,
+				   path,
+				   OPLOCK_NONE, /* CreatFlags */
+				   0, /* RootDirectoryFid */
+				   SEC_STD_SYNCHRONIZE|
+					SEC_STD_DELETE |
+					SEC_FILE_READ_DATA|
+					SEC_FILE_READ_ATTRIBUTE, /* DesiredAccess */
+				   0, /* AllocationSize */
+				   FILE_ATTRIBUTE_NORMAL, /* FileAttributes */
+				   FILE_SHARE_READ|
+					FILE_SHARE_WRITE|
+					FILE_SHARE_DELETE, /* ShareAccess */
+				   FILE_CREATE, /* CreateDisposition */
+				   0, /* CreateOptions */
+				   2, /* ImpersonationLevel */
+				   0, /* SecurityFlags */
+				   &fnum);
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("%s:%d smb1cli_ntcreatex on %s returned %s\n",
+			__FILE__,
+			__LINE__,
+			path,
+			nt_errstr(status));
+		return false;
+	}
+
+	/* Close "file" handle. */
+	(void)smb1cli_close(cli->conn,
+			    cli->timeout,
+			    cli->smb1.pid,
+			    cli->smb1.tcon,
+			    cli->smb1.session,
+			    fnum,
+			    0); /* last_modified */
+	return true;
+}
+
+static NTSTATUS smb1_unlink(struct cli_state *cli,
+			    const char *path)
+{
+	uint16_t vwv[1];
+	uint8_t *bytes = NULL;
+
+	PUSH_LE_U16(vwv, 0, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+	bytes = talloc_array(talloc_tos(), uint8_t, 1);
+	if (bytes == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+	bytes[0] = 4;
+	bytes = smb_bytes_push_str(bytes,
+				   smbXcli_conn_use_unicode(cli->conn),
+				   path,
+				   strlen(path)+1,
+				   NULL);
+	if (bytes == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	return cli_smb(talloc_tos(),
+		       cli,
+		       SMBunlink, /* command. */
+		       0, /* additional_flags. */
+		       1, /* wct. */
+		       vwv, /* vwv. */
+		       talloc_get_size(bytes), /* num_bytes. */
+		       bytes, /* bytes. */
+		       NULL, /* result parent. */
+		       0, /* min_wct. */
+		       NULL, /* return wcount. */
+		       NULL, /* return wvw. */
+		       NULL, /* return byte count. */
+		       NULL); /* return bytes. */
+}
+
+static bool test_smb1_unlink(struct cli_state *cli)
+{
+	NTSTATUS status;
+	bool retval = false;
+	bool ok = false;
+
+	/* Start clean. */
+	(void)smb1_dfs_delete(cli, "\\BAD\\BAD\\file");
+
+	/* Create a test file. */
+	ok = smb1_create_testfile(cli, "\\BAD\\BAD\\file");
+	if (!ok) {
+		printf("%s:%d failed to create test file %s\n",
+			__FILE__,
+			__LINE__,
+			"\\BAD\\BAD\\file");
+		goto err;
+	}
+
+	status = smb1_unlink(cli, "file");
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_IS_A_DIRECTORY)) {
+		printf("%s:%d SMB1unlink of %s should get "
+			"NT_STATUS_FILE_IS_A_DIRECTORY, got %s\n",
+			__FILE__,
+			__LINE__,
+			"file",
+			nt_errstr(status));
+		goto err;
+	}
+	status = smb1_unlink(cli, "\\BAD\\file");
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_IS_A_DIRECTORY)) {
+		printf("%s:%d SMB1unlink of %s should get "
+			"NT_STATUS_FILE_IS_A_DIRECTORY, got %s\n",
+			__FILE__,
+			__LINE__,
+			"\\BAD\\file",
+			nt_errstr(status));
+		goto err;
+	}
+	status = smb1_unlink(cli, "\\BAD\\BAD\\file");
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("%s:%d SMB1unlink on %s returned %s\n",
+			__FILE__,
+			__LINE__,
+			"\\BAD\\BAD\\file",
+			nt_errstr(status));
+		goto err;
+	}
+
+	retval = true;
+
+  err:
+
+	(void)smb1_dfs_delete(cli, "\\BAD\\BAD\\file");
+	return retval;
+}
+
+static NTSTATUS smb1_mkdir(struct cli_state *cli,
+			   const char *path)
+{
+	uint8_t *bytes = NULL;
+
+	bytes = talloc_array(talloc_tos(), uint8_t, 1);
+	if (bytes == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+	bytes[0] = 4;
+	bytes = smb_bytes_push_str(bytes,
+				   smbXcli_conn_use_unicode(cli->conn),
+				   path,
+				   strlen(path)+1,
+				   NULL);
+	if (bytes == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	return cli_smb(talloc_tos(),
+		       cli,
+		       SMBmkdir, /* command. */
+		       0, /* additional_flags. */
+		       0, /* wct. */
+		       NULL, /* vwv. */
+		       talloc_get_size(bytes), /* num_bytes. */
+		       bytes, /* bytes. */
+		       NULL, /* result parent. */
+		       0, /* min_wct. */
+		       NULL, /* return wcount. */
+		       NULL, /* return wvw. */
+		       NULL, /* return byte count. */
+		       NULL); /* return bytes. */
+}
+
+static bool test_smb1_mkdir(struct cli_state *cli)
+{
+	NTSTATUS status;
+	bool retval = false;
+
+	/* Start clean. */
+	(void)smb1_dfs_delete(cli, "\\BAD\\BAD\\dir");
+
+	status = smb1_mkdir(cli, "dir");
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
+		printf("%s:%d SMB1mkdir of %s should get "
+			"NT_STATUS_OBJECT_NAME_COLLISION, got %s\n",
+			__FILE__,
+			__LINE__,
+			"dir",
+			nt_errstr(status));
+		goto err;
+	}
+	status = smb1_mkdir(cli, "\\BAD\\dir");
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
+		printf("%s:%d SMB1mkdir of %s should get "
+			"NT_STATUS_OBJECT_NAME_COLLISION, got %s\n",
+			__FILE__,
+			__LINE__,
+			"\\BAD\\dir",
+			nt_errstr(status));
+		goto err;
+	}
+	status = smb1_mkdir(cli, "\\BAD\\BAD\\dir");
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("%s:%d SMB1mkdir on %s returned %s\n",
+			__FILE__,
+			__LINE__,
+			"\\BAD\\BAD\\dir",
+			nt_errstr(status));
+		goto err;
+	}
+
+	retval = true;
+
+  err:
+
+	(void)smb1_dfs_delete(cli, "\\BAD\\BAD\\dir");
+	return retval;
+}
+
+static NTSTATUS smb1_rmdir(struct cli_state *cli,
+			   const char *path)
+{
+	uint8_t *bytes = NULL;
+
+	bytes = talloc_array(talloc_tos(), uint8_t, 1);
+	if (bytes == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+	bytes[0] = 4;
+	bytes = smb_bytes_push_str(bytes,
+				   smbXcli_conn_use_unicode(cli->conn),
+				   path,
+				   strlen(path)+1,
+				   NULL);
+	if (bytes == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	return cli_smb(talloc_tos(),
+		       cli,
+		       SMBrmdir, /* command. */
+		       0, /* additional_flags. */
+		       0, /* wct. */
+		       NULL, /* vwv. */
+		       talloc_get_size(bytes), /* num_bytes. */
+		       bytes, /* bytes. */
+		       NULL, /* result parent. */
+		       0, /* min_wct. */
+		       NULL, /* return wcount. */
+		       NULL, /* return wvw. */
+		       NULL, /* return byte count. */
+		       NULL); /* return bytes. */
+}
+
+static bool test_smb1_rmdir(struct cli_state *cli)
+{
+	NTSTATUS status;
+	bool retval = false;
+
+	/* Start clean. */
+	(void)smb1_dfs_delete(cli, "\\BAD\\BAD\\dir");
+
+	status = smb1_mkdir(cli, "\\BAD\\BAD\\dir");
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("%s:%d SMB1rmdir on %s returned %s\n",
+			__FILE__,
+			__LINE__,
+			"\\BAD\\BAD\\dir",
+			nt_errstr(status));
+		goto err;
+	}
+
+	status = smb1_rmdir(cli, "dir");
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
+		printf("%s:%d SMB1rmdir of %s should get "
+			"NT_STATUS_ACCESS_DENIED, got %s\n",
+			__FILE__,
+			__LINE__,
+			"dir",
+			nt_errstr(status));
+		goto err;
+	}
+	status = smb1_rmdir(cli, "\\BAD\\dir");
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
+		printf("%s:%d SMB1rmdir of %s should get "
+			"NT_STATUS_ACCESS_DENIED, got %s\n",
+			__FILE__,
+			__LINE__,
+			"\\BAD\\dir",
+			nt_errstr(status));
+		goto err;
+	}
+	status = smb1_rmdir(cli, "\\BAD\\BAD\\dir");
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("%s:%d SMB1rmdir on %s returned %s\n",
+			__FILE__,
+			__LINE__,
+			"\\BAD\\BAD\\dir",
+			nt_errstr(status));
+		goto err;
+	}
+
+	retval = true;
+
+  err:
+
+	(void)smb1_dfs_delete(cli, "\\BAD\\BAD\\dir");
+	return retval;
+}
+
+static NTSTATUS smb1_ntcreatex(struct cli_state *cli,
+			       const char *path)
+{
+	NTSTATUS status;
+	uint16_t fnum = (uint16_t)-1;
+
+	status = smb1cli_ntcreatex(cli->conn,
+				   cli->timeout,
+				   cli->smb1.pid,
+				   cli->smb1.tcon,
+				   cli->smb1.session,
+				   path,
+				   OPLOCK_NONE, /* CreatFlags */
+				   0, /* RootDirectoryFid */
+				   SEC_STD_SYNCHRONIZE|
+					SEC_STD_DELETE |
+					SEC_FILE_READ_DATA|
+					SEC_FILE_READ_ATTRIBUTE, /* DesiredAccess */
+				   0, /* AllocationSize */
+				   FILE_ATTRIBUTE_NORMAL, /* FileAttributes */
+				   FILE_SHARE_READ|
+					FILE_SHARE_WRITE|
+					FILE_SHARE_DELETE, /* ShareAccess */
+				   FILE_CREATE, /* CreateDisposition */
+				   0, /* CreateOptions */
+				   2, /* ImpersonationLevel */
+				   0, /* SecurityFlags */
+				   &fnum);
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
+	}
+
+	/* Close "file" handle. */
+	(void)smb1cli_close(cli->conn,
+			    cli->timeout,
+			    cli->smb1.pid,
+			    cli->smb1.tcon,
+			    cli->smb1.session,
+			    fnum,
+			    0); /* last_modified */
+	return NT_STATUS_OK;
+}
+
+static bool test_smb1_ntcreatex(struct cli_state *cli)
+{
+	NTSTATUS status;
+	bool retval = false;
+
+	/* Start clean. */
+	(void)smb1_dfs_delete(cli, "\\BAD\\BAD\\ntcreateXfile");
+
+	status = smb1_ntcreatex(cli, "ntcreateXfile");
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
+		printf("%s:%d SMB1ntcreateX of %s should get "
+			"NT_STATUS_OBJECT_NAME_COLLISION, got %s\n",
+			__FILE__,
+			__LINE__,
+			"ntcreateXfile",
+			nt_errstr(status));
+		goto err;
+	}
+	status = smb1_ntcreatex(cli, "\\BAD\\ntcreateXfile");
+	if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
+		printf("%s:%d SMB1ntcreateX of %s should get "
+			"NT_STATUS_OBJECT_NAME_COLLISION, got %s\n",
+			__FILE__,
+			__LINE__,
+			"\\BAD\\ntcreateXfile",
+			nt_errstr(status));
+		goto err;
+	}
+	status = smb1_ntcreatex(cli, "\\BAD\\BAD\\ntcreateXfile");
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("%s:%d SMB1ntcreateX on %s returned %s\n",


-- 
Samba Shared Repository



More information about the samba-cvs mailing list