summaryrefslogtreecommitdiff
path: root/source4/torture/basic
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2018-03-28 11:00:59 -0700
committerKarolin Seeger <kseeger@samba.org>2018-04-06 08:21:13 +0200
commitd3ac788221e5532c11a557cf8754917f8007040e (patch)
treea0b64d5b6aa3345cd49a9872c97d0757ef4152ca /source4/torture/basic
parent2f418222ad1a6adf6252b265e1f53fd0a29cf473 (diff)
downloadsamba-d3ac788221e5532c11a557cf8754917f8007040e.tar.gz
s4: torture: Test all combinations of file create to ensure behavior is the same.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13358 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <Volker.Lendecke@SerNet.DE> (cherry picked from commit 22fe8dcb77565495886244e88bb0433363d1f80a)
Diffstat (limited to 'source4/torture/basic')
-rw-r--r--source4/torture/basic/delete.c57
1 files changed, 33 insertions, 24 deletions
diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c
index bf561e5362e..e133d5fc9af 100644
--- a/source4/torture/basic/delete.c
+++ b/source4/torture/basic/delete.c
@@ -477,31 +477,39 @@ static bool deltest9(struct torture_context *tctx, struct smbcli_state *cli1, st
{
int fnum1 = -1;
NTSTATUS status;
+ uint32_t disps[4] = {
+ NTCREATEX_DISP_SUPERSEDE,
+ NTCREATEX_DISP_OVERWRITE_IF,
+ NTCREATEX_DISP_CREATE,
+ NTCREATEX_DISP_OPEN_IF};
+ unsigned int i;
del_clean_area(cli1, cli2);
- /* This should fail - we need to set DELETE_ACCESS. */
-
- /*
- * A file or directory create with DELETE_ON_CLOSE but
- * without DELETE_ACCESS should fail with
- * NT_STATUS_INVALID_PARAMETER.
- */
-
- fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0,
- SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA,
- FILE_ATTRIBUTE_NORMAL,
- NTCREATEX_SHARE_ACCESS_NONE,
- NTCREATEX_DISP_OVERWRITE_IF,
- NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
-
- torture_assert(tctx, fnum1 == -1,
- talloc_asprintf(tctx, "open of %s succeeded should have failed!",
- fname));
+ for (i = 0; i < sizeof(disps)/sizeof(disps[0]); i++) {
+ /* This should fail - we need to set DELETE_ACCESS. */
+
+ /*
+ * A file or directory create with DELETE_ON_CLOSE but
+ * without DELETE_ACCESS should fail with
+ * NT_STATUS_INVALID_PARAMETER.
+ */
+
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0,
+ SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA,
+ FILE_ATTRIBUTE_NORMAL,
+ NTCREATEX_SHARE_ACCESS_NONE,
+ disps[i],
+ NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
+
+ torture_assert(tctx, fnum1 == -1,
+ talloc_asprintf(tctx, "open of %s succeeded "
+ "should have failed!",
+ fname));
- /* Must fail with NT_STATUS_INVALID_PARAMETER. */
- status = smbcli_nt_error(cli1->tree);
- torture_assert_ntstatus_equal(tctx,
+ /* Must fail with NT_STATUS_INVALID_PARAMETER. */
+ status = smbcli_nt_error(cli1->tree);
+ torture_assert_ntstatus_equal(tctx,
status,
NT_STATUS_INVALID_PARAMETER,
talloc_asprintf(tctx, "create of %s should return "
@@ -509,14 +517,15 @@ static bool deltest9(struct torture_context *tctx, struct smbcli_state *cli1, st
fname,
smbcli_errstr(cli1->tree)));
- /* This should fail - the file should not have been created. */
- status = smbcli_getatr(cli1->tree, fname, NULL, NULL, NULL);
- torture_assert_ntstatus_equal(tctx,
+ /* This should fail - the file should not have been created. */
+ status = smbcli_getatr(cli1->tree, fname, NULL, NULL, NULL);
+ torture_assert_ntstatus_equal(tctx,
status,
NT_STATUS_OBJECT_NAME_NOT_FOUND,
talloc_asprintf(tctx, "getattr of %s succeeded should "
"not have been created !",
fname));
+ }
return true;
}