summaryrefslogtreecommitdiff
path: root/source4/torture/basic/delete.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture/basic/delete.c')
-rw-r--r--source4/torture/basic/delete.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c
index 0c9016ca88..fbeec05d27 100644
--- a/source4/torture/basic/delete.c
+++ b/source4/torture/basic/delete.c
@@ -1197,6 +1197,66 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s
return correct;
}
+/* Test 20a ... */
+static bool deltest20a(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+{
+ int fnum1 = -1;
+ int fnum2 = -1;
+ bool correct = True;
+
+ del_clean_area(cli1, cli2);
+
+ /* Test 20a. */
+
+ /* Ensure the file doesn't already exist. */
+ smbcli_close(cli1->tree, fnum1);
+ smbcli_close(cli1->tree, fnum2);
+ smbcli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_unlink(cli1->tree, fname);
+
+ /* Firstly open and create with all access */
+ fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0,
+ SEC_RIGHTS_FILE_ALL,
+ FILE_ATTRIBUTE_NORMAL,
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE,
+ NTCREATEX_DISP_CREATE,
+ 0, 0);
+ torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)",
+ fname, smbcli_errstr(cli1->tree)));
+
+ /* Next open with all access, but add delete on close. */
+ fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0,
+ SEC_RIGHTS_FILE_ALL,
+ FILE_ATTRIBUTE_NORMAL,
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE,
+ NTCREATEX_DISP_OPEN,
+ NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
+
+ torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 2 of %s failed (%s)",
+ fname, smbcli_errstr(cli2->tree)));
+
+ /* The delete on close bit is *not* reported as being set. */
+ correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__);
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__);
+
+ smbcli_close(cli1->tree, fnum1);
+
+ correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__);
+
+ smbcli_close(cli2->tree, fnum2);
+
+ /* See if the file is deleted - should be.... */
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
+ torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail) - %s",
+ fname, smbcli_errstr(cli1->tree)));
+
+ return correct;
+}
+
/* Test 21 ... */
static bool deltest21(struct torture_context *tctx)
{
@@ -1337,7 +1397,7 @@ static bool deltest22(struct torture_context *tctx)
return correct;
}
-
+
/*
Test delete on close semantics.
*/
@@ -1367,6 +1427,7 @@ struct torture_suite *torture_test_delete(void)
torture_suite_add_2smb_test(suite, "deltest18", deltest18);
torture_suite_add_2smb_test(suite, "deltest19", deltest19);
torture_suite_add_2smb_test(suite, "deltest20", deltest20);
+ torture_suite_add_2smb_test(suite, "deltest20a", deltest20a);
torture_suite_add_simple_test(suite, "deltest21", deltest21);
torture_suite_add_simple_test(suite, "deltest22", deltest22);