svn commit: samba r20721 - in branches: SAMBA_3_0/source/smbd SAMBA_3_0_24/source/smbd

jra at samba.org jra at samba.org
Sat Jan 13 01:29:11 GMT 2007


Author: jra
Date: 2007-01-13 01:29:10 +0000 (Sat, 13 Jan 2007)
New Revision: 20721

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

Log:
Fix the search unix_convert error returns. Only open
to go...
Jeremy.

Modified:
   branches/SAMBA_3_0/source/smbd/filename.c
   branches/SAMBA_3_0/source/smbd/reply.c
   branches/SAMBA_3_0/source/smbd/trans2.c
   branches/SAMBA_3_0_24/source/smbd/filename.c
   branches/SAMBA_3_0_24/source/smbd/reply.c
   branches/SAMBA_3_0_24/source/smbd/trans2.c


Changeset:
Modified: branches/SAMBA_3_0/source/smbd/filename.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/filename.c	2007-01-13 01:07:39 UTC (rev 20720)
+++ branches/SAMBA_3_0/source/smbd/filename.c	2007-01-13 01:29:10 UTC (rev 20721)
@@ -57,6 +57,38 @@
 }
 
 /****************************************************************************
+ Cope with the differing wildcard and non-wildcard error cases.
+****************************************************************************/
+
+static NTSTATUS determine_path_error(const char *name, BOOL allow_wcard_last_component)
+{
+	const char *p;
+
+	if (!allow_wcard_last_component) {
+		/* Error code within a pathname. */
+		return NT_STATUS_OBJECT_PATH_NOT_FOUND;
+	}
+
+	/* We're terminating here so we
+	 * can be a little slower and get
+	 * the error code right. Windows
+	 * treats the last part of the pathname
+	 * separately I think, so if the last
+	 * component is a wildcard then we treat
+	 * this ./ as "end of component" */
+
+	p = strchr(name, '/');
+
+	if (!p && (ms_has_wild(name) || ISDOT(name))) {
+		/* Error code at the end of a pathname. */
+		return NT_STATUS_OBJECT_NAME_INVALID;
+	} else {
+		/* Error code within a pathname. */
+		return NT_STATUS_OBJECT_PATH_NOT_FOUND;
+	}
+}
+	
+/****************************************************************************
 This routine is called to convert names from the dos namespace to unix
 namespace. It needs to handle any case conversions, mangling, format
 changes etc.
@@ -150,8 +182,7 @@
 		if (name[1] == '\0' || name[2] == '\0') {
 			return NT_STATUS_OBJECT_NAME_INVALID;
 		} else {
-			/* Longer pathname starts with ./ */
-			return NT_STATUS_OBJECT_PATH_NOT_FOUND;
+			return determine_path_error(&name[2], allow_wcard_last_component);
 		}
 	}
 
@@ -264,32 +295,11 @@
 		/* The name cannot have a component of "." */
 
 		if (ISDOT(start)) {
-			if (end) {
-				if (allow_wcard_last_component) {
-					/* We're terminating here so we
-					 * can be a little slower and get
-					 * the error code right. Windows
-					 * treats the last part of the pathname
-					 * separately I think, so if the last
-					 * component is a wildcard then we treat
-					 * this ./ as "end of component" */
-
-					const char *p = strchr(end+1, '/');
-
-					if (!p && ms_has_wild(end+1)) {
-						/* Error code at the end of a pathname. */
-						return NT_STATUS_OBJECT_NAME_INVALID;
-					} else {
-						/* Error code within a pathname. */
-						return NT_STATUS_OBJECT_PATH_NOT_FOUND;
-					}
-				}
-				/* Error code within a pathname. */
-				return NT_STATUS_OBJECT_PATH_NOT_FOUND;
-			} else {
+			if (!end)  {
 				/* Error code at the end of a pathname. */
 				return NT_STATUS_OBJECT_NAME_INVALID;
 			}
+			return determine_path_error(end+1, allow_wcard_last_component);
 		}
 
 		/* The name cannot have a wildcard if it's not

Modified: branches/SAMBA_3_0/source/smbd/reply.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/reply.c	2007-01-13 01:07:39 UTC (rev 20720)
+++ branches/SAMBA_3_0/source/smbd/reply.c	2007-01-13 01:29:10 UTC (rev 20721)
@@ -952,7 +952,7 @@
 
 		pstrcpy(directory,path);
 		pstrcpy(dir2,path);
-		nt_status = unix_convert(conn, directory, mask_contains_wcard, NULL, &sbuf);
+		nt_status = unix_convert(conn, directory, True, NULL, &sbuf);
 		if (!NT_STATUS_IS_OK(nt_status)) {
 			END_PROFILE(SMBsearch);
 			return ERROR_NT(nt_status);

Modified: branches/SAMBA_3_0/source/smbd/trans2.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/trans2.c	2007-01-13 01:07:39 UTC (rev 20720)
+++ branches/SAMBA_3_0/source/smbd/trans2.c	2007-01-13 01:29:10 UTC (rev 20721)
@@ -1718,7 +1718,7 @@
 
 	RESOLVE_DFSPATH_WCARD(directory, conn, inbuf, outbuf);
 
-	ntstatus = unix_convert(conn, directory, mask_contains_wcard, NULL, &sbuf);
+	ntstatus = unix_convert(conn, directory, True, NULL, &sbuf);
 	if (!NT_STATUS_IS_OK(ntstatus)) {
 		return ERROR_NT(ntstatus);
 	}

Modified: branches/SAMBA_3_0_24/source/smbd/filename.c
===================================================================
--- branches/SAMBA_3_0_24/source/smbd/filename.c	2007-01-13 01:07:39 UTC (rev 20720)
+++ branches/SAMBA_3_0_24/source/smbd/filename.c	2007-01-13 01:29:10 UTC (rev 20721)
@@ -57,6 +57,38 @@
 }
 
 /****************************************************************************
+ Cope with the differing wildcard and non-wildcard error cases.
+****************************************************************************/
+
+static NTSTATUS determine_path_error(const char *name, BOOL allow_wcard_last_component)
+{
+	const char *p;
+
+	if (!allow_wcard_last_component) {
+		/* Error code within a pathname. */
+		return NT_STATUS_OBJECT_PATH_NOT_FOUND;
+	}
+
+	/* We're terminating here so we
+	 * can be a little slower and get
+	 * the error code right. Windows
+	 * treats the last part of the pathname
+	 * separately I think, so if the last
+	 * component is a wildcard then we treat
+	 * this ./ as "end of component" */
+
+	p = strchr(name, '/');
+
+	if (!p && (ms_has_wild(name) || ISDOT(name))) {
+		/* Error code at the end of a pathname. */
+		return NT_STATUS_OBJECT_NAME_INVALID;
+	} else {
+		/* Error code within a pathname. */
+		return NT_STATUS_OBJECT_PATH_NOT_FOUND;
+	}
+}
+	
+/****************************************************************************
 This routine is called to convert names from the dos namespace to unix
 namespace. It needs to handle any case conversions, mangling, format
 changes etc.
@@ -150,8 +182,7 @@
 		if (name[1] == '\0' || name[2] == '\0') {
 			return NT_STATUS_OBJECT_NAME_INVALID;
 		} else {
-			/* Longer pathname starts with ./ */
-			return NT_STATUS_OBJECT_PATH_NOT_FOUND;
+			return determine_path_error(&name[2], allow_wcard_last_component);
 		}
 	}
 
@@ -264,32 +295,11 @@
 		/* The name cannot have a component of "." */
 
 		if (ISDOT(start)) {
-			if (end) {
-				if (allow_wcard_last_component) {
-					/* We're terminating here so we
-					 * can be a little slower and get
-					 * the error code right. Windows
-					 * treats the last part of the pathname
-					 * separately I think, so if the last
-					 * component is a wildcard then we treat
-					 * this ./ as "end of component" */
-
-					const char *p = strchr(end+1, '/');
-
-					if (!p && ms_has_wild(end+1)) {
-						/* Error code at the end of a pathname. */
-						return NT_STATUS_OBJECT_NAME_INVALID;
-					} else {
-						/* Error code within a pathname. */
-						return NT_STATUS_OBJECT_PATH_NOT_FOUND;
-					}
-				}
-				/* Error code within a pathname. */
-				return NT_STATUS_OBJECT_PATH_NOT_FOUND;
-			} else {
+			if (!end)  {
 				/* Error code at the end of a pathname. */
 				return NT_STATUS_OBJECT_NAME_INVALID;
 			}
+			return determine_path_error(end+1, allow_wcard_last_component);
 		}
 
 		/* The name cannot have a wildcard if it's not

Modified: branches/SAMBA_3_0_24/source/smbd/reply.c
===================================================================
--- branches/SAMBA_3_0_24/source/smbd/reply.c	2007-01-13 01:07:39 UTC (rev 20720)
+++ branches/SAMBA_3_0_24/source/smbd/reply.c	2007-01-13 01:29:10 UTC (rev 20721)
@@ -952,7 +952,7 @@
 
 		pstrcpy(directory,path);
 		pstrcpy(dir2,path);
-		nt_status = unix_convert(conn, directory, mask_contains_wcard, NULL, &sbuf);
+		nt_status = unix_convert(conn, directory, True, NULL, &sbuf);
 		if (!NT_STATUS_IS_OK(nt_status)) {
 			END_PROFILE(SMBsearch);
 			return ERROR_NT(nt_status);

Modified: branches/SAMBA_3_0_24/source/smbd/trans2.c
===================================================================
--- branches/SAMBA_3_0_24/source/smbd/trans2.c	2007-01-13 01:07:39 UTC (rev 20720)
+++ branches/SAMBA_3_0_24/source/smbd/trans2.c	2007-01-13 01:29:10 UTC (rev 20721)
@@ -1718,7 +1718,7 @@
 
 	RESOLVE_DFSPATH_WCARD(directory, conn, inbuf, outbuf);
 
-	ntstatus = unix_convert(conn, directory, mask_contains_wcard, NULL, &sbuf);
+	ntstatus = unix_convert(conn, directory, True, NULL, &sbuf);
 	if (!NT_STATUS_IS_OK(ntstatus)) {
 		return ERROR_NT(ntstatus);
 	}



More information about the samba-cvs mailing list