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, 63 insertions, 0 deletions
diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c
index 0f7c939f5c..22d92193b9 100644
--- a/source4/torture/basic/delete.c
+++ b/source4/torture/basic/delete.c
@@ -1515,9 +1515,71 @@ static bool deltest22(struct torture_context *tctx)
CHECK_STATUS(cli1, NT_STATUS_DELETE_PENDING);
+ smbcli_close(cli1->tree, dnum2);
+ CHECK_STATUS(cli1, NT_STATUS_OK);
+
return correct;
}
+/* Test 23 - Second directory open fails when delete is pending. */
+static bool deltest23(struct torture_context *tctx,
+ struct smbcli_state *cli1,
+ struct smbcli_state *cli2)
+{
+ int dnum1 = -1;
+ int dnum2 = -1;
+ bool correct = true;
+ NTSTATUS status;
+
+ del_clean_area(cli1, cli2);
+
+ /* Test 23 -- Basic delete on close for directories. */
+
+ /* Open a directory */
+ dnum1 = smbcli_nt_create_full(cli1->tree, dname, 0,
+ SEC_FILE_READ_DATA|
+ SEC_FILE_WRITE_DATA|
+ SEC_STD_DELETE,
+ FILE_ATTRIBUTE_DIRECTORY,
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE,
+ NTCREATEX_DISP_CREATE,
+ NTCREATEX_OPTIONS_DIRECTORY, 0);
+
+ torture_assert(tctx, dnum1 != -1, talloc_asprintf(tctx,
+ "open of %s failed: %s!",
+ dname, smbcli_errstr(cli1->tree)));
+
+ correct &= check_delete_on_close(tctx, cli1, dnum1, dname, false,
+ __location__);
+
+ /* Set delete on close */
+ status = smbcli_nt_delete_on_close(cli1->tree, dnum1, true);
+
+ /* Attempt opening the directory again. It should fail. */
+ dnum2 = smbcli_nt_create_full(cli1->tree, dname, 0,
+ SEC_FILE_READ_DATA|
+ SEC_FILE_WRITE_DATA|
+ SEC_STD_DELETE,
+ FILE_ATTRIBUTE_DIRECTORY,
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE,
+ NTCREATEX_DISP_OPEN,
+ NTCREATEX_OPTIONS_DIRECTORY, 0);
+
+ torture_assert(tctx, dnum2 == -1, talloc_asprintf(tctx,
+ "open of %s succeeded: %s. It should have failed "
+ "with NT_STATUS_DELETE_PENDING",
+ dname, smbcli_errstr(cli1->tree)));
+
+ torture_assert_ntstatus_equal(tctx, smbcli_nt_error(cli1->tree),
+ NT_STATUS_DELETE_PENDING, "smbcli_open failed");
+
+ return true;
+}
+
/*
Test delete on close semantics.
*/
@@ -1551,6 +1613,7 @@ struct torture_suite *torture_test_delete(void)
torture_suite_add_2smb_test(suite, "deltest20b", deltest20b);
torture_suite_add_simple_test(suite, "deltest21", deltest21);
torture_suite_add_simple_test(suite, "deltest22", deltest22);
+ torture_suite_add_2smb_test(suite, "deltest23", deltest23);
return suite;
}