s3:smbd: let unix_convert() only do the optimistic stat() if no wildcards are
authorStefan Metzmacher <metze@samba.org>
Tue, 7 Sep 2010 15:31:45 +0000 (17:31 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 18 Apr 2011 15:59:22 +0000 (17:59 +0200)
used

Inspired by:

commit c96d487ae3c65c17b377bb316adac4b5775448f3
Author: Jeremy Allison <jra@samba.org>
Date:   Wed Nov 25 13:17:56 2009 -0800

    Make us pass RAW-CHKPATH with a case sensitive share.

metze

source3/smbd/filename.c

index 81532a06dac8c819e66f168886ac71dc04763d29..a69f51a9a94c1a71023d885ae2bc63aae87f1362 100644 (file)
@@ -276,35 +276,37 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
                goto fail;
        }
 
-       /*
-        * stat the name - if it exists then we are all done!
-        */
+       if (!name_has_wildcard) {
+               /*
+                * stat the name - if it exists then we are all done!
+                */
 
-       if (posix_pathnames) {
-               ret = SMB_VFS_LSTAT(conn,name,&st);
-       } else {
-               ret = SMB_VFS_STAT(conn,name,&st);
-       }
+               if (posix_pathnames) {
+                       ret = SMB_VFS_LSTAT(conn,name,&st);
+               } else {
+                       ret = SMB_VFS_STAT(conn,name,&st);
+               }
 
-       if (ret == 0) {
-               /* Ensure we catch all names with in "/."
-                  this is disallowed under Windows. */
-               const char *p = strstr(name, "/."); /* mb safe. */
-               if (p) {
-                       if (p[2] == '/') {
-                               /* Error code within a pathname. */
-                               result = NT_STATUS_OBJECT_PATH_NOT_FOUND;
-                               goto fail;
-                       } else if (p[2] == '\0') {
-                               /* Error code at the end of a pathname. */
-                               result = NT_STATUS_OBJECT_NAME_INVALID;
-                               goto fail;
+               if (ret == 0) {
+                       /* Ensure we catch all names with in "/."
+                          this is disallowed under Windows. */
+                       const char *p = strstr(name, "/."); /* mb safe. */
+                       if (p) {
+                               if (p[2] == '/') {
+                                       /* Error code within a pathname. */
+                                       result = NT_STATUS_OBJECT_PATH_NOT_FOUND;
+                                       goto fail;
+                               } else if (p[2] == '\0') {
+                                       /* Error code at the end of a pathname. */
+                                       result = NT_STATUS_OBJECT_NAME_INVALID;
+                                       goto fail;
+                               }
                        }
+                       stat_cache_add(orig_path, name, conn->case_sensitive);
+                       DEBUG(5,("conversion finished %s -> %s\n",orig_path, name));
+                       *pst = st;
+                       goto done;
                }
-               stat_cache_add(orig_path, name, conn->case_sensitive);
-               DEBUG(5,("conversion finished %s -> %s\n",orig_path, name));
-               *pst = st;
-               goto done;
        }
 
        DEBUG(5,("unix_convert begin: name = %s, dirpath = %s, start = %s\n",