Correct fix for bug 6781 - Cannot rename subfolders in Explorer view with recent...
authorJeremy Allison <jra@samba.org>
Wed, 7 Oct 2009 22:46:57 +0000 (15:46 -0700)
committerKarolin Seeger <kseeger@samba.org>
Fri, 9 Oct 2009 06:40:59 +0000 (08:40 +0200)
source3/smbd/files.c

index 54c4c732ec04de636fb8ea9b50e005793ddefdb0..6f82686d5339697dbc0346acc566bdd909f5a3e7 100644 (file)
@@ -385,13 +385,12 @@ bool file_find_subpath(files_struct *dir_fsp)
 {
        files_struct *fsp;
        size_t dlen;
-       bool ret = false;
        char *d_fullname = talloc_asprintf(talloc_tos(),
                                        "%s/%s",
                                        dir_fsp->conn->connectpath,
                                        dir_fsp->fsp_name);
        if (!d_fullname) {
-               goto out;
+               return false;
        }
 
        dlen = strlen(d_fullname);
@@ -408,28 +407,21 @@ bool file_find_subpath(files_struct *dir_fsp)
                                        fsp->conn->connectpath,
                                        fsp->fsp_name);
 
-               if (strnequal(d_fullname, d1_fullname, dlen)) {
-                       int d1_len = strlen(d1_fullname);
-
-                       /*
-                        * If the open file is a second file handle to the
-                        * same name or is a stream on the original file, then
-                        * don't return true.
-                        */
-                       if (d1_len == dlen || d1_fullname[dlen] == ':') {
-                               TALLOC_FREE(d1_fullname);
-                               continue;
-                       }
-
+                /*
+                * If the open file has a path that is a longer
+                * component, then it's a subpath.
+                */
+               if (strnequal(d_fullname, d1_fullname, dlen) &&
+                               (d1_fullname[dlen] == '/')) {
                        TALLOC_FREE(d1_fullname);
-                       ret = true;
-                       goto out;
+                       TALLOC_FREE(d_fullname);
+                       return true;
                }
                TALLOC_FREE(d1_fullname);
-       } 
- out:
+       }
+
        TALLOC_FREE(d_fullname);
-       return ret;
+       return false;
 }
 
 /****************************************************************************