diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-08-03 17:10:26 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:31:06 -0500 |
commit | d4c4f16f944f33188077200c69df0c876bdf8c7f (patch) | |
tree | f74b8b6298b82843d0f95f39d7bcfa82c2fc1bae /source4/torture | |
parent | 7937a353db9afe1ef6062c77ca5bfb9bad8319c4 (diff) | |
download | samba-d4c4f16f944f33188077200c69df0c876bdf8c7f.tar.gz samba-d4c4f16f944f33188077200c69df0c876bdf8c7f.tar.bz2 samba-d4c4f16f944f33188077200c69df0c876bdf8c7f.zip |
r9006: expanded RAW-UNLINK test to test directory delete on close with non-empty directory,
as per discussions during jeremys talk at cifs2005
(This used to be commit b28b2108c7f3e94fb47a706fb1d550354074730d)
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/raw/unlink.c | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/source4/torture/raw/unlink.c b/source4/torture/raw/unlink.c index b2eb7eae60..a83a6bf25a 100644 --- a/source4/torture/raw/unlink.c +++ b/source4/torture/raw/unlink.c @@ -20,6 +20,7 @@ #include "includes.h" #include "system/filesys.h" +#include "librpc/gen_ndr/ndr_security.h" #define CHECK_STATUS(status, correct) do { \ if (!NT_STATUS_EQUAL(status, correct)) { \ @@ -169,6 +170,7 @@ done: */ static BOOL test_delete_on_close(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { + union smb_open op; struct smb_unlink io; struct smb_rmdir dio; NTSTATUS status; @@ -271,6 +273,108 @@ static BOOL test_delete_on_close(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) status = smb_raw_rmdir(cli->tree, &dio); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + printf("Testing open dir with delete_on_close\n"); + fnum = create_directory_handle(cli->tree, dname); + smbcli_close(cli->tree, fnum); + fnum2 = create_complex_file(cli, mem_ctx, inside); + smbcli_close(cli->tree, fnum2); + + op.generic.level = RAW_OPEN_NTCREATEX; + op.ntcreatex.in.root_fid = 0; + op.ntcreatex.in.flags = 0; + op.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; + op.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY |NTCREATEX_OPTIONS_DELETE_ON_CLOSE; + op.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; + op.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + op.ntcreatex.in.alloc_size = 0; + op.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; + op.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + op.ntcreatex.in.security_flags = 0; + op.ntcreatex.in.fname = dname; + + status = smb_raw_open(cli->tree, mem_ctx, &op); + CHECK_STATUS(status, NT_STATUS_OK); + fnum = op.ntcreatex.out.fnum; + + smbcli_close(cli->tree, fnum); + + status = smb_raw_rmdir(cli->tree, &dio); + CHECK_STATUS(status, NT_STATUS_DIRECTORY_NOT_EMPTY); + + + printf("Testing double open dir with second delete_on_close\n"); + fnum = create_directory_handle(cli->tree, dname); + fnum2 = create_complex_file(cli, mem_ctx, inside); + smbcli_close(cli->tree, fnum2); + + op.generic.level = RAW_OPEN_NTCREATEX; + op.ntcreatex.in.root_fid = 0; + op.ntcreatex.in.flags = 0; + op.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; + op.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY |NTCREATEX_OPTIONS_DELETE_ON_CLOSE; + op.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; + op.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + op.ntcreatex.in.alloc_size = 0; + op.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; + op.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + op.ntcreatex.in.security_flags = 0; + op.ntcreatex.in.fname = dname; + + status = smb_raw_open(cli->tree, mem_ctx, &op); + CHECK_STATUS(status, NT_STATUS_OK); + fnum2 = op.ntcreatex.out.fnum; + + smbcli_close(cli->tree, fnum2); + smbcli_close(cli->tree, fnum); + + status = smb_raw_rmdir(cli->tree, &dio); + CHECK_STATUS(status, NT_STATUS_DIRECTORY_NOT_EMPTY); + + + printf("Testing pre-existing open dir with second delete_on_close\n"); + fnum = create_directory_handle(cli->tree, dname); + smbcli_close(cli->tree, fnum); + + fnum = create_complex_file(cli, mem_ctx, inside); + smbcli_close(cli->tree, fnum); + + /* we have a dir with a file in it, no handles open */ + + op.generic.level = RAW_OPEN_NTCREATEX; + op.ntcreatex.in.root_fid = 0; + op.ntcreatex.in.flags = 0; + op.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; + op.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY |NTCREATEX_OPTIONS_DELETE_ON_CLOSE; + op.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; + op.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_DELETE; + op.ntcreatex.in.alloc_size = 0; + op.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; + op.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + op.ntcreatex.in.security_flags = 0; + op.ntcreatex.in.fname = dname; + + status = smb_raw_open(cli->tree, mem_ctx, &op); + CHECK_STATUS(status, NT_STATUS_OK); + fnum = op.ntcreatex.out.fnum; + + /* open without delete on close */ + op.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; + status = smb_raw_open(cli->tree, mem_ctx, &op); + CHECK_STATUS(status, NT_STATUS_OK); + fnum2 = op.ntcreatex.out.fnum; + + /* close 2nd file handle */ + smbcli_close(cli->tree, fnum2); + + status = smb_raw_rmdir(cli->tree, &dio); + CHECK_STATUS(status, NT_STATUS_DIRECTORY_NOT_EMPTY); + + + smbcli_close(cli->tree, fnum); + + status = smb_raw_rmdir(cli->tree, &dio); + CHECK_STATUS(status, NT_STATUS_DIRECTORY_NOT_EMPTY); + done: smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); |