diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-03-23 15:03:52 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:59:08 -0500 |
commit | 41a6591628bc7dcb4751b8c2752e6d288d579276 (patch) | |
tree | 60cba39607003f4245ddb82e5ebfdf929438989a /source4/torture | |
parent | 13f45733a3b3c4985864ad19cae9735aa48feec8 (diff) | |
download | samba-41a6591628bc7dcb4751b8c2752e6d288d579276.tar.gz samba-41a6591628bc7dcb4751b8c2752e6d288d579276.tar.bz2 samba-41a6591628bc7dcb4751b8c2752e6d288d579276.zip |
r14680: add some tests which demonstrate that closing the dir handle
triggers an empty notify reply with NT_STATUS_OK
metze
(This used to be commit 590dd49207342031fed902701f4214f3b1d6397c)
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/raw/notify.c | 199 |
1 files changed, 199 insertions, 0 deletions
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c index 38b1fe64b3..e781ffca87 100644 --- a/source4/torture/raw/notify.c +++ b/source4/torture/raw/notify.c @@ -61,6 +61,7 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) NTSTATUS status; struct smb_notify notify; union smb_open io; + union smb_close cl; int i, count, fnum, fnum2; struct smbcli_request *req, *req2; extern int torture_numops; @@ -229,6 +230,21 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) CHECK_VAL(notify.out.changes[i].action, NOTIFY_ACTION_REMOVED); } + printf("testing if a close() on the dir handle triggers the notify reply\n"); + + notify.in.file.fnum = fnum; + req = smb_raw_changenotify_send(cli->tree, ¬ify); + + cl.close.level = RAW_CLOSE_CLOSE; + cl.close.in.file.fnum = fnum; + cl.close.in.write_time = 0; + status = smb_raw_close(cli->tree, &cl); + CHECK_STATUS(status, NT_STATUS_OK); + + status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VAL(notify.out.num_changes, 0); + done: smb_raw_exit(cli->session); return ret; @@ -293,6 +309,186 @@ done: return ret; } +/* + basic testing of change notifies followed by a tdis +*/ +static BOOL test_notify_tdis(TALLOC_CTX *mem_ctx) +{ + BOOL ret = True; + NTSTATUS status; + struct smb_notify notify; + union smb_open io; + int fnum; + struct smbcli_request *req; + struct smbcli_state *cli = NULL; + + printf("TESTING CHANGE NOTIFY FOLLOWED BY TDIS\n"); + + if (!torture_open_connection(&cli)) { + return False; + } + + /* + get a handle on the directory + */ + io.generic.level = RAW_OPEN_NTCREATEX; + io.ntcreatex.in.root_fid = 0; + io.ntcreatex.in.flags = 0; + io.ntcreatex.in.access_mask = SEC_FILE_ALL; + io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; + io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + io.ntcreatex.in.alloc_size = 0; + io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; + io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + io.ntcreatex.in.security_flags = 0; + io.ntcreatex.in.fname = BASEDIR; + + status = smb_raw_open(cli->tree, mem_ctx, &io); + CHECK_STATUS(status, NT_STATUS_OK); + fnum = io.ntcreatex.out.file.fnum; + + /* ask for a change notify, + on file or directory name changes */ + notify.in.buffer_size = 1000; + notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; + notify.in.file.fnum = fnum; + notify.in.recursive = True; + + req = smb_raw_changenotify_send(cli->tree, ¬ify); + + status = smbcli_tdis(cli); + CHECK_STATUS(status, NT_STATUS_OK); + + status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VAL(notify.out.num_changes, 0); + +done: + torture_close_connection(cli); + return ret; +} + +/* + basic testing of change notifies followed by a exit +*/ +static BOOL test_notify_exit(TALLOC_CTX *mem_ctx) +{ + BOOL ret = True; + NTSTATUS status; + struct smb_notify notify; + union smb_open io; + int fnum; + struct smbcli_request *req; + struct smbcli_state *cli = NULL; + + printf("TESTING CHANGE NOTIFY FOLLOWED BY EXIT\n"); + + if (!torture_open_connection(&cli)) { + return False; + } + + /* + get a handle on the directory + */ + io.generic.level = RAW_OPEN_NTCREATEX; + io.ntcreatex.in.root_fid = 0; + io.ntcreatex.in.flags = 0; + io.ntcreatex.in.access_mask = SEC_FILE_ALL; + io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; + io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + io.ntcreatex.in.alloc_size = 0; + io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; + io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + io.ntcreatex.in.security_flags = 0; + io.ntcreatex.in.fname = BASEDIR; + + status = smb_raw_open(cli->tree, mem_ctx, &io); + CHECK_STATUS(status, NT_STATUS_OK); + fnum = io.ntcreatex.out.file.fnum; + + /* ask for a change notify, + on file or directory name changes */ + notify.in.buffer_size = 1000; + notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; + notify.in.file.fnum = fnum; + notify.in.recursive = True; + + req = smb_raw_changenotify_send(cli->tree, ¬ify); + + status = smb_raw_exit(cli->session); + CHECK_STATUS(status, NT_STATUS_OK); + + status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VAL(notify.out.num_changes, 0); + +done: + torture_close_connection(cli); + return ret; +} + +/* + basic testing of change notifies followed by a ulogoff +*/ +static BOOL test_notify_ulogoff(TALLOC_CTX *mem_ctx) +{ + BOOL ret = True; + NTSTATUS status; + struct smb_notify notify; + union smb_open io; + int fnum; + struct smbcli_request *req; + struct smbcli_state *cli = NULL; + + printf("TESTING CHANGE NOTIFY FOLLOWED BY ULOGOFF\n"); + + if (!torture_open_connection(&cli)) { + return False; + } + + /* + get a handle on the directory + */ + io.generic.level = RAW_OPEN_NTCREATEX; + io.ntcreatex.in.root_fid = 0; + io.ntcreatex.in.flags = 0; + io.ntcreatex.in.access_mask = SEC_FILE_ALL; + io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; + io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + io.ntcreatex.in.alloc_size = 0; + io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; + io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + io.ntcreatex.in.security_flags = 0; + io.ntcreatex.in.fname = BASEDIR; + + status = smb_raw_open(cli->tree, mem_ctx, &io); + CHECK_STATUS(status, NT_STATUS_OK); + fnum = io.ntcreatex.out.file.fnum; + + /* ask for a change notify, + on file or directory name changes */ + notify.in.buffer_size = 1000; + notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; + notify.in.file.fnum = fnum; + notify.in.recursive = True; + + req = smb_raw_changenotify_send(cli->tree, ¬ify); + + status = smb_raw_ulogoff(cli->session); + CHECK_STATUS(status, NT_STATUS_OK); + + status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VAL(notify.out.num_changes, 0); + +done: + torture_close_connection(cli); + return ret; +} + /* basic testing of change notify */ @@ -314,6 +510,9 @@ BOOL torture_raw_notify(void) ret &= test_notify_dir(cli, mem_ctx); ret &= test_notify_file(cli, mem_ctx); + ret &= test_notify_tdis(mem_ctx); + ret &= test_notify_exit(mem_ctx); + ret &= test_notify_ulogoff(mem_ctx); smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); |