summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/torture/raw/notify.c121
1 files changed, 119 insertions, 2 deletions
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index 841238ea3d..493229e7ef 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -292,8 +292,6 @@ static BOOL check_rename_reply(struct smbcli_state *cli,
return False;
}
-
-
/*
testing of recursive change notify
*/
@@ -425,6 +423,124 @@ done:
return ret;
}
+/*
+ testing of change notify mask change
+*/
+static BOOL test_notify_mask_change(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+{
+ BOOL ret = True;
+ NTSTATUS status;
+ union smb_notify notify;
+ union smb_open io;
+ int fnum;
+ struct smbcli_request *req1, *req2;
+ union smb_setfileinfo sfinfo;
+
+ printf("TESTING CHANGE NOTIFY WITH MASK CHANGE\n");
+
+ /*
+ 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. Setup both with and without recursion */
+ notify.nttrans.level = RAW_NOTIFY_NTTRANS;
+ notify.nttrans.in.buffer_size = 1000;
+ notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_ATTRIBUTES;
+ notify.nttrans.in.file.fnum = fnum;
+
+ notify.nttrans.in.recursive = True;
+ req1 = smb_raw_changenotify_send(cli->tree, &notify);
+
+ notify.nttrans.in.recursive = False;
+ req2 = smb_raw_changenotify_send(cli->tree, &notify);
+
+ /* cancel initial requests so the buffer is setup */
+ smb_raw_ntcancel(req1);
+ status = smb_raw_changenotify_recv(req1, mem_ctx, &notify);
+ CHECK_STATUS(status, NT_STATUS_CANCELLED);
+
+ smb_raw_ntcancel(req2);
+ status = smb_raw_changenotify_recv(req2, mem_ctx, &notify);
+ CHECK_STATUS(status, NT_STATUS_CANCELLED);
+
+ notify.nttrans.in.recursive = True;
+ req1 = smb_raw_changenotify_send(cli->tree, &notify);
+
+ /* Set to hidden then back again. */
+ smbcli_close(cli->tree, smbcli_open(cli->tree, BASEDIR "\\tname1", O_CREAT, 0));
+ smbcli_setatr(cli->tree, BASEDIR "\\tname1", FILE_ATTRIBUTE_HIDDEN, 0);
+ smbcli_unlink(cli->tree, BASEDIR "\\tname1");
+
+ status = smb_raw_changenotify_recv(req1, mem_ctx, &notify);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ CHECK_VAL(notify.nttrans.out.num_changes, 1);
+ CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_MODIFIED);
+ CHECK_WSTR(notify.nttrans.out.changes[0].name, "tname1", STR_UNICODE);
+
+ /* Now try and change the mask to include other events.
+ * This should not work - once the mask is set on a directory
+ * fnum it seems to be fixed until the fnum is closed. */
+
+ notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_CREATION;
+ notify.nttrans.in.recursive = True;
+ req1 = smb_raw_changenotify_send(cli->tree, &notify);
+
+ notify.nttrans.in.recursive = False;
+ req2 = smb_raw_changenotify_send(cli->tree, &notify);
+
+ smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name");
+ smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name\\subname1");
+ smbcli_close(cli->tree,
+ smbcli_open(cli->tree, BASEDIR "\\subdir-name\\subname2", O_CREAT, 0));
+ smbcli_rename(cli->tree, BASEDIR "\\subdir-name\\subname1", BASEDIR "\\subdir-name\\subname1-r");
+ smbcli_rename(cli->tree, BASEDIR "\\subdir-name\\subname2", BASEDIR "\\subname2-r");
+ smbcli_rename(cli->tree, BASEDIR "\\subname2-r", BASEDIR "\\subname3-r");
+
+ smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name\\subname1-r");
+ smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name");
+ smbcli_unlink(cli->tree, BASEDIR "\\subname3-r");
+
+ status = smb_raw_changenotify_recv(req1, mem_ctx, &notify);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ CHECK_VAL(notify.nttrans.out.num_changes, 1);
+ CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_MODIFIED);
+ CHECK_WSTR(notify.nttrans.out.changes[0].name, "subname2-r", STR_UNICODE);
+
+ status = smb_raw_changenotify_recv(req2, mem_ctx, &notify);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ CHECK_VAL(notify.nttrans.out.num_changes, 1);
+ CHECK_VAL(notify.nttrans.out.changes[0].action, NOTIFY_ACTION_MODIFIED);
+ CHECK_WSTR(notify.nttrans.out.changes[0].name, "subname3-r", STR_UNICODE);
+
+ if (!ret) {
+ goto done;
+ }
+
+done:
+ smb_raw_exit(cli->session);
+ return ret;
+}
+
/*
testing of mask bits for change notify
@@ -1190,6 +1306,7 @@ BOOL torture_raw_notify(struct torture_context *torture)
ret &= test_notify_dir(cli, cli2, mem_ctx);
ret &= test_notify_mask(cli, mem_ctx);
ret &= test_notify_recursive(cli, mem_ctx);
+ ret &= test_notify_mask_change(cli, mem_ctx);
ret &= test_notify_file(cli, mem_ctx);
ret &= test_notify_tdis(mem_ctx);
ret &= test_notify_exit(mem_ctx);