r20721: Fix the search unix_convert error returns. Only open
authorJeremy Allison <jra@samba.org>
Sat, 13 Jan 2007 01:29:10 +0000 (01:29 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:17:06 +0000 (12:17 -0500)
to go...
Jeremy.
(This used to be commit 89f03a8db40365f99c6755ff19a4bfbf8d1bd316)

source3/smbd/filename.c
source3/smbd/reply.c
source3/smbd/trans2.c

index 44916200daae7b629559ab6126d7dde92a74e942..dd1e0de20f2ee87afc1e1c25fe7bdfb23bd6e96a 100644 (file)
@@ -56,6 +56,38 @@ static BOOL mangled_equal(const char *name1, const char *name2,
        return strequal(name1, tmpname);
 }
 
+/****************************************************************************
+ 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
@@ -150,8 +182,7 @@ NTSTATUS unix_convert(connection_struct *conn,
                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 @@ NTSTATUS unix_convert(connection_struct *conn,
                /* 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
index e42c663cecf6d6735cfdb84165a2692517d4b5ab..21c8b13b5c2b1be04f1ff792908395c4a8f892b6 100644 (file)
@@ -952,7 +952,7 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
 
                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);
index 2cfb692b024968771cc70e36486fc2c794761f16..7bdecd45cae96ee414c4906388ba74c57d876ee7 100644 (file)
@@ -1718,7 +1718,7 @@ close_if_end = %d requires_resume_key = %d level = 0x%x, max_data_bytes = %d\n",
 
        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);
        }