From: Jeremy Allison Date: Wed, 7 Sep 2022 18:23:45 +0000 (-0700) Subject: s3: smbtorture3: Add test_smb1_ntcreatex() DFS test to run_smb1_dfs_operations(). X-Git-Tag: talloc-2.4.0~1052 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18bdcd85e4b24647d1225b79ff7f9607e753df2e;p=thirdparty%2Fsamba.git s3: smbtorture3: Add test_smb1_ntcreatex() DFS test to run_smb1_dfs_operations(). Passes against Windows. Signed-off-by: Jeremy Allison --- diff --git a/source3/torture/test_smb1_dfs.c b/source3/torture/test_smb1_dfs.c index d7b7913e953..7a9a40fd461 100644 --- a/source3/torture/test_smb1_dfs.c +++ b/source3/torture/test_smb1_dfs.c @@ -2677,6 +2677,95 @@ static bool test_smb1_rmdir(struct cli_state *cli) return retval; } +static NTSTATUS smb1_ntcreatex(struct cli_state *cli, + const char *path) +{ + NTSTATUS status; + uint16_t fnum = (uint16_t)-1; + + status = smb1cli_ntcreatex(cli->conn, + cli->timeout, + cli->smb1.pid, + cli->smb1.tcon, + cli->smb1.session, + path, + OPLOCK_NONE, /* CreatFlags */ + 0, /* RootDirectoryFid */ + SEC_STD_SYNCHRONIZE| + SEC_STD_DELETE | + SEC_FILE_READ_DATA| + SEC_FILE_READ_ATTRIBUTE, /* DesiredAccess */ + 0, /* AllocationSize */ + FILE_ATTRIBUTE_NORMAL, /* FileAttributes */ + FILE_SHARE_READ| + FILE_SHARE_WRITE| + FILE_SHARE_DELETE, /* ShareAccess */ + FILE_CREATE, /* CreateDisposition */ + 0, /* CreateOptions */ + 2, /* ImpersonationLevel */ + 0, /* SecurityFlags */ + &fnum); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + /* Close "file" handle. */ + (void)smb1cli_close(cli->conn, + cli->timeout, + cli->smb1.pid, + cli->smb1.tcon, + cli->smb1.session, + fnum, + 0); /* last_modified */ + return NT_STATUS_OK; +} + +static bool test_smb1_ntcreatex(struct cli_state *cli) +{ + NTSTATUS status; + bool retval = false; + + /* Start clean. */ + (void)smb1_dfs_delete(cli, "\\BAD\\BAD\\ntcreateXfile"); + + status = smb1_ntcreatex(cli, "ntcreateXfile"); + if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) { + printf("%s:%d SMB1ntcreateX of %s should get " + "NT_STATUS_OBJECT_NAME_COLLISION, got %s\n", + __FILE__, + __LINE__, + "ntcreateXfile", + nt_errstr(status)); + goto err; + } + status = smb1_ntcreatex(cli, "\\BAD\\ntcreateXfile"); + if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) { + printf("%s:%d SMB1ntcreateX of %s should get " + "NT_STATUS_OBJECT_NAME_COLLISION, got %s\n", + __FILE__, + __LINE__, + "\\BAD\\ntcreateXfile", + nt_errstr(status)); + goto err; + } + status = smb1_ntcreatex(cli, "\\BAD\\BAD\\ntcreateXfile"); + if (!NT_STATUS_IS_OK(status)) { + printf("%s:%d SMB1ntcreateX on %s returned %s\n", + __FILE__, + __LINE__, + "\\BAD\\BAD\\ntcreateXfile", + nt_errstr(status)); + goto err; + } + + retval = true; + + err: + + (void)smb1_dfs_delete(cli, "\\BAD\\BAD\\ntcreateXfile"); + return retval; +} + /* * "Raw" test of different SMB1 operations to a DFS share. * We must (mostly) use the lower level smb1cli_XXXX() interfaces, @@ -2734,6 +2823,11 @@ bool run_smb1_dfs_operations(int dummy) goto err; } + ok = test_smb1_ntcreatex(cli); + if (!ok) { + goto err; + } + retval = true; err: