s3: torture: Add MS-FSA style terminating '/' and '\\' test - SMB2-PATH-SLASH.
authorJeremy Allison <jra@samba.org>
Thu, 26 Sep 2019 19:36:18 +0000 (12:36 -0700)
committerRalph Boehme <slow@samba.org>
Wed, 2 Oct 2019 08:01:41 +0000 (08:01 +0000)
[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>
selftest/knownfail
source3/selftest/tests.py
source3/torture/proto.h
source3/torture/test_smb2.c
source3/torture/torture.c

index 7b54b77a7084bd4bddd3820f758a27f49ccb7929..cd2323de3b38d6f7c5b344fef20bc28edc67cae9 100644 (file)
@@ -9,6 +9,8 @@
  ^samba3.smbtorture_s3.crypt_server\(nt4_dc\).SMB2-SESSION-REAUTH # expected to give ACCESS_DENIED SMB2.1 doesn't have encryption
 ^samba3.smbtorture_s3.crypt_server\(nt4_dc\).SMB2-SESSION-RECONNECT # expected to give CONNECTION_DISCONNECTED, we need to fix the test
 ^samba3.smbtorture_s3.plain.*SMB2-DIR-FSYNC.*\(ad_dc_ntvfs\)
+^samba3.smbtorture_s3.plain.*SMB2-PATH-SLASH.*\(ad_dc_ntvfs\)
+^samba3.smbtorture_s3.plain.*SMB2-PATH-SLASH.*\(fileserver\)
 ^samba3.smbtorture_s3.plain.LOCK11.*\(ad_dc_ntvfs\)
 ^samba3.smb2.session enc.reconnect # expected to give CONNECTION_DISCONNECTED, we need to fix the test
 ^samba3.raw.session enc # expected to give ACCESS_DENIED as SMB1 encryption isn't used
index b6445205c5060e1175efa191baacae555ca2a0c5..f3676a879a3860dad6d1a0ea2fe1b909d06f1fb8 100755 (executable)
@@ -94,6 +94,7 @@ tests = ["FDPASS", "LOCK1", "LOCK2", "LOCK3", "LOCK4", "LOCK5", "LOCK6", "LOCK7"
          "CASE-INSENSITIVE-CREATE", "SMB2-BASIC", "NTTRANS-FSCTL", "SMB2-NEGPROT",
          "SMB2-SESSION-REAUTH", "SMB2-SESSION-RECONNECT", "SMB2-FTRUNCATE",
          "SMB2-ANONYMOUS", "SMB2-DIR-FSYNC",
+        "SMB2-PATH-SLASH",
          "CLEANUP1",
          "CLEANUP2",
          "CLEANUP4",
index 65144f3faab63cb13d7be2a937ce2b58b5756b95..578d784b4100f6359ec0454af451264cd1f1869a 100644 (file)
@@ -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);
index 0cfb68cbbef3836c73feccebafcc8b951372770c..4e6d103b339c1a0ea1022e07ee717c217d61e1e1 100644 (file)
@@ -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;
+}
index a8f451e9ac2f58a8923834d46ba213377fdefd8e..052ff15a2e037bf5bb29ebe8f35f9063a3160500 100644 (file)
@@ -14578,6 +14578,10 @@ static struct {
                .name  = "SMB2-DIR-FSYNC",
                .fn    = run_smb2_dir_fsync,
        },
+       {
+               .name  = "SMB2-PATH-SLASH",
+               .fn    = run_smb2_path_slash,
+       },
        {
                .name  = "CLEANUP1",
                .fn    = run_cleanup1,