]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbtorture3: Add test_smb1_mkdir() DFS test to run_smb1_dfs_operations().
authorJeremy Allison <jra@samba.org>
Wed, 7 Sep 2022 00:49:05 +0000 (17:49 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 14 Sep 2022 17:33:37 +0000 (17:33 +0000)
Passes against Windows.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
source3/torture/test_smb1_dfs.c

index 211be4e1aba0d8d411aea2df341c774405d3ec66..129f37efc5c603ea99e3a083cdbc312e54f5cccd 100644 (file)
@@ -2505,6 +2505,87 @@ static bool test_smb1_unlink(struct cli_state *cli)
        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;
+}
+
 /*
  * "Raw" test of different SMB1 operations to a DFS share.
  * We must (mostly) use the lower level smb1cli_XXXX() interfaces,
@@ -2552,6 +2633,12 @@ bool run_smb1_dfs_operations(int dummy)
                goto err;
        }
 
+       ok = test_smb1_mkdir(cli);
+       if (!ok) {
+               goto err;
+       }
+
+
        retval = true;
 
   err: