diff options
author | Volker Lendecke <vlendec@samba.org> | 2005-12-09 21:49:11 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:47:15 -0500 |
commit | 10275774499a6ff25efa066ce82d802641285772 (patch) | |
tree | 521160ffc768a335953708197cc351f79891c58b /source4/torture | |
parent | 126f8b8b6a0d065d3b3f959aa7bea2bcf0ee9c57 (diff) | |
download | samba-10275774499a6ff25efa066ce82d802641285772.tar.gz samba-10275774499a6ff25efa066ce82d802641285772.tar.bz2 samba-10275774499a6ff25efa066ce82d802641285772.zip |
r12154: Torture test for bug # 3303.
Jeremy, to run this against Samba3 at all you need to insert a "goto line 957"
in line 548. Without this we fail some tests before # 16 and bail out.
While looking at it, you wanted to fix the directory-based ones a while
ago.... :-))
Volker
(This used to be commit 45cd224102f21364c4f6ca056417f956f21eb02e)
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/basic/delete.c | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 60db6a78ed..d1ee98941c 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -148,6 +148,7 @@ BOOL torture_test_delete(void) struct smbcli_state *cli1; struct smbcli_state *cli2 = NULL; const char *fname = "\\delete.file"; + const char *fname_new = "\\delete.new"; const char *dirname = "\\delete.dir"; int fnum1 = -1; int fnum2 = -1; @@ -951,6 +952,130 @@ BOOL torture_test_delete(void) printf("fifteenth delete on close test succeeded.\n"); + /* Test 16: delete on close under rename */ + + smbcli_setatr(cli1->tree, fname, 0, 0); + smbcli_unlink(cli1->tree, fname); + smbcli_unlink(cli1->tree, fname_new); + + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SEC_FILE_READ_DATA, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OVERWRITE_IF, + 0, 0); + + if (fnum1 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + status = smbcli_rename(cli2->tree, fname, fname_new); + + if (!NT_STATUS_IS_OK(status)) { + printf("(%s) renaming failed: %s !\n", + __location__, nt_errstr(status)); + correct = False; + goto fail; + } + + fnum2 = smbcli_nt_create_full(cli2->tree, fname_new, 0, + SEC_GENERIC_ALL, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OVERWRITE_IF, + 0, 0); + + if (fnum2 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, fname_new, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + status = smbcli_nt_delete_on_close(cli2->tree, fnum2, True); + + if (!NT_STATUS_IS_OK(status)) { + printf("(%s) setting delete_on_close on file failed !\n", + __location__); + correct = False; + goto fail; + } + + smbcli_close(cli2->tree, fnum2); + + /* The file should be around under the new name, there's a second + * handle open */ + + if (!check_delete_on_close(cli1, fnum1, fname_new, True)) { + printf("(%s) checking delete on close on file %s failed!\n", + __location__, fname_new); + correct = False; + goto fail; + } + + fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, + SEC_GENERIC_ALL, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OVERWRITE_IF, + 0, 0); + + if (fnum2 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + smbcli_close(cli2->tree, fnum2); + smbcli_close(cli1->tree, fnum1); + + fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, + SEC_FILE_READ_EA, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + 0, 0); + + if (fnum1 == -1) { + printf("(%s) open - 1 of %s failed (%s)\n", + __location__, fname, smbcli_errstr(cli1->tree)); + correct = False; + goto fail; + } + + smbcli_close(cli1->tree, fnum1); + + fnum1 = smbcli_nt_create_full(cli1->tree, fname_new, 0, + SEC_FILE_READ_EA, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE| + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, + 0, 0); + + if (fnum1 != -1) { + printf("(%s) smbcli_open succeeded, should have " + "failed\n", __location__); + smbcli_close(cli1->tree, fnum1); + correct = False; + goto fail; + } + + printf("sixteenth delete on close test succeeded.\n"); + printf("finished delete test\n"); fail: |