svn commit: samba r23734 - in branches/SAMBA_4_0/source/torture/raw: .

jra at samba.org jra at samba.org
Fri Jul 6 19:45:03 GMT 2007


Author: jra
Date: 2007-07-06 19:45:01 +0000 (Fri, 06 Jul 2007)
New Revision: 23734

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23734

Log:
Add a test to prove tridge's theory that the mask, once set
on an open directory handle, is never changed. (He's right btw :-).
Jeremy.

Modified:
   branches/SAMBA_4_0/source/torture/raw/notify.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/raw/notify.c
===================================================================
--- branches/SAMBA_4_0/source/torture/raw/notify.c	2007-07-06 18:49:49 UTC (rev 23733)
+++ branches/SAMBA_4_0/source/torture/raw/notify.c	2007-07-06 19:45:01 UTC (rev 23734)
@@ -292,8 +292,6 @@
 	return False;
 }
 
-
-
 /* 
    testing of recursive change notify
 */
@@ -425,7 +423,125 @@
 	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 @@
 	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);



More information about the samba-cvs mailing list