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

vlendec at samba.org vlendec at samba.org
Mon Jan 8 14:14:19 GMT 2007


Author: vlendec
Date: 2007-01-08 14:14:18 +0000 (Mon, 08 Jan 2007)
New Revision: 20609

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

Log:
Additional torture test for our bad_path handling. Most of it is disabled for
now, there are calls (for example trans2ffirst) which are quite dubious.

Volker

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


Changeset:
Modified: branches/SAMBA_4_0/source/torture/raw/samba3misc.c
===================================================================
--- branches/SAMBA_4_0/source/torture/raw/samba3misc.c	2007-01-08 14:08:34 UTC (rev 20608)
+++ branches/SAMBA_4_0/source/torture/raw/samba3misc.c	2007-01-08 14:14:18 UTC (rev 20609)
@@ -25,6 +25,7 @@
 #include "system/filesys.h"
 #include "libcli/libcli.h"
 #include "torture/util.h"
+#include "torture/raw/proto.h"
 
 #define CHECK_STATUS(status, correct) do { \
 	if (!NT_STATUS_EQUAL(status, correct)) { \
@@ -219,10 +220,12 @@
 
 BOOL torture_samba3_badpath(struct torture_context *torture)
 {
-	struct smbcli_state *cli_nt;
-	struct smbcli_state *cli_dos;
+	struct smbcli_state *cli_nt = NULL;
+	struct smbcli_state *cli_dos = NULL;
 	const char *fname = "test.txt";
 	const char *dirname = "testdir";
+	const char *invname = "testdir\\notthere.txt";
+	const char *invpath = "test.txt\\test.txt";
 	char *fpath;
 	int fnum;
 	NTSTATUS status;
@@ -263,6 +266,7 @@
 		goto fail;
 	}
 
+	smbcli_unlink(cli_nt->tree, fname);
 	smbcli_deltree(cli_nt->tree, dirname);
 
 	status = smbcli_mkdir(cli_nt->tree, dirname);
@@ -303,6 +307,14 @@
 	}
 	smbcli_close(cli_nt->tree, fnum);
 
+	fnum = smbcli_open(cli_nt->tree, fname, O_RDWR | O_CREAT, DENY_NONE);
+	if (fnum == -1) {
+		d_printf("Could not create file %s: %s\n", fname,
+			 smbcli_errstr(cli_nt->tree));
+		goto fail;
+	}
+	smbcli_close(cli_nt->tree, fnum);
+
 	/*
 	 * Do a whole bunch of error code checks on chkpath
 	 */
@@ -452,6 +464,201 @@
 	status = raw_smbcli_open(cli_dos->tree, "<\\bla", O_RDONLY, DENY_NONE, NULL);
 	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidname));
 
+	/*
+	 * Walk the Samba3 unix_convert bad_path handling. Some interesting
+	 * error paths around...
+	 */
+
+	status = smbcli_chkpath(cli_nt->tree, invpath);
+	CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+	status = smbcli_chkpath(cli_dos->tree, invpath);
+	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+	status = smbcli_getatr(cli_nt->tree, invpath, NULL, NULL, NULL);
+	CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+	status = smbcli_getatr(cli_dos->tree, invpath, NULL, NULL, NULL);
+	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+	status = smbcli_setatr(cli_nt->tree, invpath, 0, 0);
+	CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+	status = smbcli_setatr(cli_dos->tree, invpath, 0, 0);
+	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+	status = smbcli_setatr(cli_nt->tree, invpath, FILE_ATTRIBUTE_NORMAL,
+			       0);
+	CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+	status = smbcli_setatr(cli_dos->tree, invpath, FILE_ATTRIBUTE_NORMAL,
+			       0);
+	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+	status = smbcli_setatr(cli_nt->tree, invname, 0, 0);
+	CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
+	status = smbcli_setatr(cli_dos->tree, invname, 0, 0);
+	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadfile));
+
+	/*
+	 * reply_search returns STATUS_NO_MORE_FILES on invalid path
+	 */
+
+	goto done; 		/* We're not yet fully there, but keep it
+				 * in */
+
+	status = torture_single_search(cli_nt, mem_ctx, invpath,
+				       RAW_SEARCH_SEARCH,
+				       RAW_SEARCH_DATA_SEARCH, 0, NULL);
+	CHECK_STATUS(status, STATUS_NO_MORE_FILES);
+	status = torture_single_search(cli_dos, mem_ctx, invpath,
+				       RAW_SEARCH_SEARCH,
+				       RAW_SEARCH_DATA_SEARCH, 0, NULL);
+	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRnofiles));
+
+	/*
+	 * ... whereas t2search gets you NT_STATUS_INVALID_PARAMETER
+	 */
+
+	status = torture_single_search(cli_nt, mem_ctx, dirname,
+				       RAW_SEARCH_TRANS2,
+				       RAW_SEARCH_DATA_STANDARD, 0xf, NULL);
+	CHECK_STATUS(status, STATUS_NO_MORE_FILES);
+	status = torture_single_search(cli_dos, mem_ctx, dirname,
+				       RAW_SEARCH_TRANS2,
+				       RAW_SEARCH_DATA_STANDARD, 0xf, NULL);
+	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRnofiles));
+
+	status = torture_single_search(cli_nt, mem_ctx, invpath,
+				       RAW_SEARCH_TRANS2,
+				       RAW_SEARCH_DATA_STANDARD, 0xf, NULL);
+	CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+	status = torture_single_search(cli_dos, mem_ctx, invpath,
+				       RAW_SEARCH_TRANS2,
+				       RAW_SEARCH_DATA_STANDARD, 0xf, NULL);
+	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidparam));
+
+	{
+		union smb_open o;
+		o.openold.level = RAW_OPEN_OPEN;
+		o.openold.in.open_mode = 0;
+		o.openold.in.search_attrs = 0;
+		o.openold.in.fname = invpath;
+
+		status = smb_raw_open(cli_nt->tree, mem_ctx, &o);
+		CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+		status = smb_raw_open(cli_dos->tree, mem_ctx, &o);
+		CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+		ZERO_STRUCT(o);
+		o.openx.level = RAW_OPEN_OPENX;
+		o.openx.in.fname = invpath;
+		o.openx.in.open_func = OPENX_OPEN_FUNC_OPEN;
+
+		status = smb_raw_open(cli_nt->tree, mem_ctx, &o);
+		CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+		status = smb_raw_open(cli_dos->tree, mem_ctx, &o);
+		CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+		ZERO_STRUCT(o);
+		o.mknew.level = RAW_OPEN_MKNEW;
+		o.mknew.in.fname = invpath;
+
+		status = smb_raw_open(cli_nt->tree, mem_ctx, &o);
+		CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+		status = smb_raw_open(cli_dos->tree, mem_ctx, &o);
+		CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+		ZERO_STRUCT(o);
+		o.ntcreatex.level = RAW_OPEN_NTCREATEX;
+		o.ntcreatex.in.fname = invpath;
+
+		status = smb_raw_open(cli_nt->tree, mem_ctx, &o);
+		CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+		status = smb_raw_open(cli_dos->tree, mem_ctx, &o);
+		CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+		ZERO_STRUCT(o);
+		o.nttrans.level = RAW_OPEN_NTTRANS_CREATE;
+		o.nttrans.in.fname = invpath;
+
+		status = smb_raw_open(cli_nt->tree, mem_ctx, &o);
+		CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+		status = smb_raw_open(cli_dos->tree, mem_ctx, &o);
+		CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+		/*
+		 * TODO: Check t2open
+		 */
+
+#if 0
+		/*
+		 * This call seems completely broken on W2k3. It gives back a
+		 * fid, and when you later want to close it the server returns
+		 * INVALID_HANDLE....
+		 */
+
+		/*
+		 * W2k3 puts the ctemp files into the root of the share, it
+		 * seems to ignore the directory given. And, the file name
+		 * given back seems to be bogus. The real file name is
+		 * prepended with a "t"...
+		 */
+
+		ZERO_STRUCT(o);
+		o.ctemp.level = RAW_OPEN_CTEMP;
+		o.ctemp.in.directory = invpath;
+
+		status = smb_raw_open(cli_nt->tree, mem_ctx, &o);
+		if (NT_STATUS_IS_OK(status)) {
+			smbcli_nt_delete_on_close(
+				cli_nt->tree, o.ctemp.out.file.fnum, True);
+			smbcli_close(cli_nt->tree, o.ctemp.out.file.fnum);
+		}
+		CHECK_STATUS(status, NT_STATUS_OK);
+		status = smb_raw_open(cli_dos->tree, mem_ctx, &o);
+		if (NT_STATUS_IS_OK(status)) {
+			smbcli_nt_delete_on_close(
+				cli_nt->tree, o.ctemp.out.file.fnum, True);
+			smbcli_close(cli_nt->tree, o.ctemp.out.file.fnum);
+		}
+		CHECK_STATUS(status, NT_STATUS_OK);
+#endif
+	}
+
+	status = smbcli_unlink(cli_nt->tree, invpath);
+	CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+	status = smbcli_unlink(cli_dos->tree, invpath);
+	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+	status = smbcli_mkdir(cli_nt->tree, invpath);
+	CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+	status = smbcli_mkdir(cli_dos->tree, invpath);
+	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+	status = smbcli_rmdir(cli_nt->tree, invpath);
+	CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+	status = smbcli_rmdir(cli_dos->tree, invpath);
+	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+	status = smbcli_rename(cli_nt->tree, invpath, "");
+	CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD);
+	status = smbcli_rename(cli_dos->tree, invpath, "");
+	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidpath));
+
+	status = smbcli_rename(cli_nt->tree, "", invpath);
+	CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD);
+	status = smbcli_rename(cli_dos->tree, "", invpath);
+	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidpath));
+
+	status = smbcli_rename(cli_nt->tree, invpath, invpath);
+	CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+	status = smbcli_rename(cli_dos->tree, invpath, invpath);
+	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+	status = smbcli_qpathinfo(cli_nt->tree, invpath, NULL, NULL, NULL,
+				  NULL, NULL);
+	CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+	status = smbcli_qpathinfo(cli_dos->tree, invpath, NULL, NULL, NULL,
+				  NULL, NULL);
+	CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
 	goto done;
 
  fail:
@@ -460,6 +667,7 @@
  done:
 	if (cli_nt != NULL) {
 		smbcli_deltree(cli_nt->tree, dirname);
+		smbcli_unlink(cli_nt->tree, fname);
 		torture_close_connection(cli_nt);
 	}
 	if (cli_dos != NULL) {



More information about the samba-cvs mailing list