diff options
author | Aravind Srinivasan <aravind.srinivasan@isilon.com> | 2009-11-17 12:28:34 -0800 |
---|---|---|
committer | Steven Danneman <steven.danneman@isilon.com> | 2009-12-07 16:10:24 -0800 |
commit | 0c42d65d7cbc24b96f0e9ec700d32da860060174 (patch) | |
tree | 8ad17ce6ca1407629ff2c53a893032066951c0c2 /source4/torture/basic | |
parent | a24631007ea4dcf25e777070d783608f988a5f94 (diff) | |
download | samba-0c42d65d7cbc24b96f0e9ec700d32da860060174.tar.gz samba-0c42d65d7cbc24b96f0e9ec700d32da860060174.tar.bz2 samba-0c42d65d7cbc24b96f0e9ec700d32da860060174.zip |
s4/torture: add delete-on-close test for directories
This test opens a directory with delete on close, opens it again,
and checks to make sure that the second open returned with
NT_STATUS_DELETE_PENDING.
Diffstat (limited to 'source4/torture/basic')
-rw-r--r-- | source4/torture/basic/delete.c | 63 |
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; } |