shadow_copy2: fix shadow_copy2_strip_snapshot() in the classical case
authorMichael Adam <obnox@samba.org>
Wed, 29 May 2013 15:16:23 +0000 (17:16 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 4 Oct 2013 20:21:26 +0000 (09:21 +1300)
I.e., fix detection of already converted names.

This is done by using the shadow_copy2_snapshot_path() function
and comparing if the input string starts with that.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/modules/vfs_shadow_copy2.c

index 17eb8ba6f92e4a42bcf918ec1ffcdc22cfa8d770..8c2e7679469941eb27542c6f005535b93e7ad93f 100644 (file)
@@ -381,6 +381,36 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx,
                        goto no_snapshot;
                }
                TALLOC_FREE(insert);
+       } else {
+               char *snapshot_path;
+               char *s;
+
+               snapshot_path = shadow_copy2_snapshot_path(talloc_tos(),
+                                                          handle,
+                                                          timestamp);
+               if (snapshot_path == NULL) {
+                       errno = ENOMEM;
+                       return false;
+               }
+
+               DEBUG(10, (__location__ " path: '%s'.\n"
+                          "snapshot path: '%s'\n", name, snapshot_path));
+
+               s = strstr(name, snapshot_path);
+               if (s == name) {
+                       /*
+                        * this starts with "snapshot_basepath/GMT-Token"
+                        * so it is already a converted absolute
+                        * path. Don't process further.
+                        */
+                       DEBUG(10, (__location__ ": path '%s' starts with "
+                                  "snapshot path '%s' (not in "
+                                  "snapdirseverywhere mode) ==> "
+                                  "already converted\n", name, snapshot_path));
+                       talloc_free(snapshot_path);
+                       goto no_snapshot;
+               }
+               talloc_free(snapshot_path);
        }
 
        if (pstripped != NULL) {