summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-02-01 03:36:04 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:51:41 -0500
commit1b33f040d376fe05a2a0bd79602cc5273d8aca5b (patch)
tree5c87f9e40d3f6436fad3ae3971b5a8eff9ad13e4 /source4
parent4a9d08319b45a8a721f39c00067c64487b6b5be9 (diff)
downloadsamba-1b33f040d376fe05a2a0bd79602cc5273d8aca5b.tar.gz
samba-1b33f040d376fe05a2a0bd79602cc5273d8aca5b.tar.bz2
samba-1b33f040d376fe05a2a0bd79602cc5273d8aca5b.zip
r13271: Do the same tests with directories.
Jeremy. (This used to be commit 7986af2ece2e707ee3d98dadb37af9fc5126d138)
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/basic/delete.c163
1 files changed, 161 insertions, 2 deletions
diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c
index 50db9a09eb..e76f387f80 100644
--- a/source4/torture/basic/delete.c
+++ b/source4/torture/basic/delete.c
@@ -949,8 +949,6 @@ BOOL torture_test_delete(void)
smbcli_close(cli1->tree, dnum1);
- /* Now it should be gone... */
-
printf("fifteenth delete on close test succeeded.\n");
/* Test 16: delete on close under rename */
@@ -1219,6 +1217,165 @@ BOOL torture_test_delete(void)
printf("eighteenth delete on close test succeeded.\n");
+ /* Test 19. With directories. */
+
+ /* Ensure the file doesn't already exist. */
+ smbcli_close(cli1->tree, fnum1);
+ smbcli_close(cli1->tree, fnum2);
+
+ smbcli_deltree(cli1->tree, dirname);
+
+ /* Firstly create with all access, but delete on close. */
+ fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 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|NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
+
+ if (fnum1 == -1) {
+ printf("(%s) open - 1 of %s failed (%s)\n",
+ __location__, dirname, smbcli_errstr(cli1->tree));
+ correct = False;
+ goto fail;
+ }
+
+ /* The delete on close bit is *not* reported as being set. */
+ check_delete_on_close(cli1, fnum1, dirname, False);
+
+ /* Now try opening again for read-only. */
+ fnum2 = smbcli_nt_create_full(cli1->tree, dirname, 0,
+ SEC_RIGHTS_FILE_READ,
+ FILE_ATTRIBUTE_DIRECTORY,
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE,
+ NTCREATEX_DISP_OPEN,
+ NTCREATEX_OPTIONS_DIRECTORY, 0);
+
+
+ /* Should work. */
+ if (fnum2 == -1) {
+ printf("(%s) open - 1 of %s failed (%s)\n",
+ __location__, dirname, smbcli_errstr(cli1->tree));
+ correct = False;
+ goto fail;
+ }
+
+ /* Now close both.... */
+ smbcli_close(cli1->tree, fnum1);
+ smbcli_close(cli1->tree, fnum2);
+
+ /* And the directory should be deleted ! */
+ fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0,
+ SEC_RIGHTS_FILE_READ,
+ FILE_ATTRIBUTE_DIRECTORY,
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE,
+ NTCREATEX_DISP_OPEN,
+ NTCREATEX_OPTIONS_DIRECTORY, 0);
+ if (fnum1 != -1) {
+ printf("(%s) open of %s succeeded (should fail)\n",
+ __location__, dirname);
+ correct = False;
+ goto fail;
+ }
+
+ printf("nineteenth delete on close test succeeded.\n");
+
+ /* Test 20. */
+
+ smbcli_deltree(cli1->tree, dirname);
+
+ /* Firstly open and create with all access */
+ fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 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);
+
+ if (fnum1 == -1) {
+ printf("(%s) open - 1 of %s failed (%s)\n",
+ __location__, dirname, smbcli_errstr(cli1->tree));
+ correct = False;
+ goto fail;
+ }
+
+ /* And close - just to create the directory. */
+ smbcli_close(cli1->tree, fnum1);
+
+ /* Next open with all access, but add delete on close. */
+ fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 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|NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
+
+ if (fnum1 == -1) {
+ printf("(%s) open - 1 of %s failed (%s)\n",
+ __location__, fname, smbcli_errstr(cli1->tree));
+ correct = False;
+ goto fail;
+ }
+
+ /* The delete on close bit is *not* reported as being set. */
+ check_delete_on_close(cli1, fnum1, dirname, False);
+
+ /* Now try opening again for read-only. */
+ fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0,
+ SEC_RIGHTS_FILE_READ,
+ FILE_ATTRIBUTE_DIRECTORY,
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE,
+ NTCREATEX_DISP_OPEN,
+ NTCREATEX_OPTIONS_DIRECTORY, 0);
+
+ /* Should work. */
+ if (fnum2 == -1) {
+ printf("(%s) open - 1 of %s failed (%s)\n",
+ __location__, dirname, smbcli_errstr(cli1->tree));
+ correct = False;
+ goto fail;
+ }
+
+ /* Now close both.... */
+ smbcli_close(cli1->tree, fnum1);
+ smbcli_close(cli1->tree, fnum2);
+
+ /* See if the file is deleted - shouldn't be.... */
+ fnum1 = smbcli_nt_create_full(cli1->tree, dirname, 0,
+ SEC_RIGHTS_FILE_READ,
+ FILE_ATTRIBUTE_DIRECTORY,
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE,
+ NTCREATEX_DISP_OPEN,
+ NTCREATEX_OPTIONS_DIRECTORY, 0);
+ if (fnum1 == -1) {
+ printf("(%s) open of %s failed (should succeed)\n",
+ __location__, dirname);
+ correct = False;
+ goto fail;
+ }
+
+ printf("twentieth delete on close test succeeded.\n");
+
printf("finished delete test\n");
fail:
@@ -1231,6 +1388,8 @@ BOOL torture_test_delete(void)
smbcli_setatr(cli1->tree, fname, 0, 0);
smbcli_unlink(cli1->tree, fname);
+ smbcli_deltree(cli1->tree, dirname);
+
if (!torture_close_connection(cli1)) {
correct = False;
}