summaryrefslogtreecommitdiff
path: root/source3/torture
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2019-09-26 12:36:18 -0700
committerRalph Boehme <slow@samba.org>2019-10-02 08:01:41 +0000
commit5642f288c895467e32a39430af709cc48198e7c1 (patch)
tree1e1d9f7f63b84fc6c29aefd9b289fe989e3f72b1 /source3/torture
parent32d6cc84cf8e0cf278b5715b8a9d66b7c0a2a6d2 (diff)
downloadsamba-5642f288c895467e32a39430af709cc48198e7c1.tar.gz
s3: torture: Add MS-FSA style terminating '/' and '\\' test - SMB2-PATH-SLASH.
[MS-FSA] 2.1.5.1 Server Requests an Open of a File. Checks how to behave on both files and directories. Tested against Windows 10 server - passes. Currently smbd fails this. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'source3/torture')
-rw-r--r--source3/torture/proto.h1
-rw-r--r--source3/torture/test_smb2.c205
-rw-r--r--source3/torture/torture.c4
3 files changed, 210 insertions, 0 deletions
diff --git a/source3/torture/proto.h b/source3/torture/proto.h
index 65144f3faab..578d784b410 100644
--- a/source3/torture/proto.h
+++ b/source3/torture/proto.h
@@ -102,6 +102,7 @@ bool run_smb2_multi_channel(int dummy);
bool run_smb2_session_reauth(int dummy);
bool run_smb2_ftruncate(int dummy);
bool run_smb2_dir_fsync(int dummy);
+bool run_smb2_path_slash(int dummy);
bool run_chain3(int dummy);
bool run_local_conv_auth_info(int dummy);
bool run_local_sprintf_append(int dummy);
diff --git a/source3/torture/test_smb2.c b/source3/torture/test_smb2.c
index 0cfb68cbbef..4e6d103b339 100644
--- a/source3/torture/test_smb2.c
+++ b/source3/torture/test_smb2.c
@@ -2335,3 +2335,208 @@ bool run_smb2_dir_fsync(int dummy)
}
return true;
}
+
+bool run_smb2_path_slash(int dummy)
+{
+ struct cli_state *cli = NULL;
+ NTSTATUS status;
+ uint64_t fid_persistent;
+ uint64_t fid_volatile;
+ const char *dname_noslash = "smb2_dir_slash";
+ const char *dname_backslash = "smb2_dir_slash\\";
+ const char *dname_slash = "smb2_dir_slash/";
+ const char *fname_noslash = "smb2_file_slash";
+ const char *fname_backslash = "smb2_file_slash\\";
+ const char *fname_slash = "smb2_file_slash/";
+
+ printf("Starting SMB2-PATH-SLASH\n");
+
+ if (!torture_init_connection(&cli)) {
+ return false;
+ }
+
+ status = smbXcli_negprot(cli->conn, cli->timeout,
+ PROTOCOL_SMB2_02, PROTOCOL_SMB2_02);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("smbXcli_negprot returned %s\n", nt_errstr(status));
+ return false;
+ }
+
+ status = cli_session_setup_creds(cli, torture_creds);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_session_setup returned %s\n", nt_errstr(status));
+ return false;
+ }
+
+ status = cli_tree_connect(cli, share, "?????", NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("cli_tree_connect returned %s\n", nt_errstr(status));
+ return false;
+ }
+
+ (void)cli_unlink(cli, dname_noslash, 0);
+ (void)cli_rmdir(cli, dname_noslash);
+ (void)cli_unlink(cli, fname_noslash, 0);
+ (void)cli_rmdir(cli, fname_noslash);
+
+ /* Try to create a directory with the backslash name. */
+ status = smb2cli_create(cli->conn,
+ cli->timeout,
+ cli->smb2.session,
+ cli->smb2.tcon,
+ dname_backslash,
+ SMB2_OPLOCK_LEVEL_NONE, /* oplock_level, */
+ SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level, */
+ FILE_READ_DATA|FILE_READ_ATTRIBUTES, /* desired_access, */
+ 0, /* file_attributes, */
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access, */
+ FILE_CREATE, /* create_disposition, */
+ FILE_DIRECTORY_FILE, /* create_options, */
+ NULL, /* smb2_create_blobs *blobs */
+ &fid_persistent,
+ &fid_volatile,
+ NULL, NULL, NULL);
+
+ /* directory ending in '\\' should be success. */
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("smb2cli_create '%s' returned %s - "
+ "should be NT_STATUS_OK\n",
+ dname_backslash,
+ nt_errstr(status));
+ return false;
+ }
+ status = smb2cli_close(cli->conn,
+ cli->timeout,
+ cli->smb2.session,
+ cli->smb2.tcon,
+ 0,
+ fid_persistent,
+ fid_volatile);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("smb2cli_close returned %s\n", nt_errstr(status));
+ return false;
+ }
+
+ (void)cli_rmdir(cli, dname_noslash);
+
+ /* Try to create a directory with the slash name. */
+ status = smb2cli_create(cli->conn,
+ cli->timeout,
+ cli->smb2.session,
+ cli->smb2.tcon,
+ dname_slash,
+ SMB2_OPLOCK_LEVEL_NONE, /* oplock_level, */
+ SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level, */
+ FILE_READ_DATA|FILE_READ_ATTRIBUTES, /* desired_access, */
+ 0, /* file_attributes, */
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access, */
+ FILE_CREATE, /* create_disposition, */
+ FILE_DIRECTORY_FILE, /* create_options, */
+ NULL, /* smb2_create_blobs *blobs */
+ &fid_persistent,
+ &fid_volatile,
+ NULL, NULL, NULL);
+
+ /* directory ending in '/' is an error. */
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_INVALID)) {
+ printf("smb2cli_create '%s' returned %s - "
+ "should be NT_STATUS_OBJECT_NAME_INVALID\n",
+ dname_slash,
+ nt_errstr(status));
+ if (NT_STATUS_IS_OK(status)) {
+ (void)smb2cli_close(cli->conn,
+ cli->timeout,
+ cli->smb2.session,
+ cli->smb2.tcon,
+ 0,
+ fid_persistent,
+ fid_volatile);
+ }
+ (void)cli_rmdir(cli, dname_noslash);
+ return false;
+ }
+
+ (void)cli_rmdir(cli, dname_noslash);
+
+ /* Try to create a file with the backslash name. */
+ status = smb2cli_create(cli->conn,
+ cli->timeout,
+ cli->smb2.session,
+ cli->smb2.tcon,
+ fname_backslash,
+ SMB2_OPLOCK_LEVEL_NONE, /* oplock_level, */
+ SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level, */
+ FILE_READ_DATA|FILE_READ_ATTRIBUTES, /* desired_access, */
+ 0, /* file_attributes, */
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access, */
+ FILE_CREATE, /* create_disposition, */
+ FILE_NON_DIRECTORY_FILE, /* create_options, */
+ NULL, /* smb2_create_blobs *blobs */
+ &fid_persistent,
+ &fid_volatile,
+ NULL, NULL, NULL);
+
+ /* file ending in '\\' should be error. */
+
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_INVALID)) {
+ printf("smb2cli_create '%s' returned %s - "
+ "should be NT_STATUS_OBJECT_NAME_INVALID\n",
+ fname_backslash,
+ nt_errstr(status));
+ if (NT_STATUS_IS_OK(status)) {
+ (void)smb2cli_close(cli->conn,
+ cli->timeout,
+ cli->smb2.session,
+ cli->smb2.tcon,
+ 0,
+ fid_persistent,
+ fid_volatile);
+ }
+ (void)cli_unlink(cli, fname_noslash, 0);
+ return false;
+ }
+
+ (void)cli_unlink(cli, fname_noslash, 0);
+
+ /* Try to create a file with the slash name. */
+ status = smb2cli_create(cli->conn,
+ cli->timeout,
+ cli->smb2.session,
+ cli->smb2.tcon,
+ fname_slash,
+ SMB2_OPLOCK_LEVEL_NONE, /* oplock_level, */
+ SMB2_IMPERSONATION_IMPERSONATION, /* impersonation_level, */
+ FILE_READ_DATA|FILE_READ_ATTRIBUTES, /* desired_access, */
+ 0, /* file_attributes, */
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access, */
+ FILE_CREATE, /* create_disposition, */
+ FILE_NON_DIRECTORY_FILE, /* create_options, */
+ NULL, /* smb2_create_blobs *blobs */
+ &fid_persistent,
+ &fid_volatile,
+ NULL, NULL, NULL);
+
+ /* file ending in '/' should be error. */
+
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_INVALID)) {
+ printf("smb2cli_create '%s' returned %s - "
+ "should be NT_STATUS_OBJECT_NAME_INVALID\n",
+ fname_slash,
+ nt_errstr(status));
+ if (NT_STATUS_IS_OK(status)) {
+ (void)smb2cli_close(cli->conn,
+ cli->timeout,
+ cli->smb2.session,
+ cli->smb2.tcon,
+ 0,
+ fid_persistent,
+ fid_volatile);
+ }
+ (void)cli_unlink(cli, fname_noslash, 0);
+ return false;
+ }
+
+ (void)cli_unlink(cli, fname_noslash, 0);
+ return true;
+}
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index a8f451e9ac2..052ff15a2e0 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -14579,6 +14579,10 @@ static struct {
.fn = run_smb2_dir_fsync,
},
{
+ .name = "SMB2-PATH-SLASH",
+ .fn = run_smb2_path_slash,
+ },
+ {
.name = "CLEANUP1",
.fn = run_cleanup1,
},