]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbtorture3: Add test_smb1_rmdir() DFS test to run_smb1_dfs_operations().
authorJeremy Allison <jra@samba.org>
Wed, 7 Sep 2022 17:41:53 +0000 (10:41 -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 129f37efc5c603ea99e3a083cdbc312e54f5cccd..d7b7913e9531535d4e9cc111256f21cdf1ce894c 100644 (file)
@@ -2586,6 +2586,97 @@ static bool test_smb1_mkdir(struct cli_state *cli)
        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;
+}
+
 /*
  * "Raw" test of different SMB1 operations to a DFS share.
  * We must (mostly) use the lower level smb1cli_XXXX() interfaces,
@@ -2638,6 +2729,10 @@ bool run_smb1_dfs_operations(int dummy)
                goto err;
        }
 
+       ok = test_smb1_rmdir(cli);
+       if (!ok) {
+               goto err;
+       }
 
        retval = true;