From: Jeremy Allison Date: Wed, 7 Sep 2022 17:41:53 +0000 (-0700) Subject: s3: smbtorture3: Add test_smb1_rmdir() DFS test to run_smb1_dfs_operations(). X-Git-Tag: talloc-2.4.0~1053 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7b06ea37c6aba15a62a905192a46fcc5211871a;p=thirdparty%2Fsamba.git s3: smbtorture3: Add test_smb1_rmdir() DFS test to run_smb1_dfs_operations(). Passes against Windows. Signed-off-by: Jeremy Allison Reviewed-by: Noel Power --- diff --git a/source3/torture/test_smb1_dfs.c b/source3/torture/test_smb1_dfs.c index 129f37efc5c..d7b7913e953 100644 --- a/source3/torture/test_smb1_dfs.c +++ b/source3/torture/test_smb1_dfs.c @@ -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;