shadow_copy2: introduce "shadow:mountpoint" option
authorMichael Adam <obnox@samba.org>
Fri, 31 May 2013 14:36:33 +0000 (16:36 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 4 Oct 2013 20:21:10 +0000 (09:21 +1300)
Possiblity to explicitly set the share's mount point.
This is useful mainly for debugging and testing purposes.

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

index d584fa92af1ce9ab5f7a856279c4ef8e67a52749..afe2ff4638d16720fdfff0673e3348acb9f7fbf4 100644 (file)
@@ -1583,6 +1583,7 @@ static int shadow_copy2_connect(struct vfs_handle_struct *handle,
        const char *gmt_format;
        const char *sort_order;
        const char *basedir;
+       const char *mount_point;
 
        DEBUG(10, (__location__ ": cnum[%u], connectpath[%s]\n",
                   (unsigned)handle->conn->cnum,
@@ -1649,11 +1650,43 @@ static int shadow_copy2_connect(struct vfs_handle_struct *handle,
                return -1;
        }
 
-       config->mount_point = shadow_copy2_find_mount_point(config, handle);
-       if (config->mount_point == NULL) {
-               DEBUG(0, (__location__ ": shadow_copy2_find_mount_point "
-                         "failed: %s\n", strerror(errno)));
-               return -1;
+       mount_point = lp_parm_const_string(SNUM(handle->conn),
+                                          "shadow", "mountpoint", NULL);
+       if (mount_point != NULL) {
+               if (mount_point[0] != '/') {
+                       DEBUG(1, (__location__ " Warning: 'mountpoint' is "
+                                 "relative ('%s'), but it has to be an "
+                                 "absolute path. Ignoring provided value.\n",
+                                 mount_point));
+                       mount_point = NULL;
+               } else {
+                       char *p;
+                       p = strstr(handle->conn->connectpath, mount_point);
+                       if (p != handle->conn->connectpath) {
+                               DEBUG(1, ("Warning: mount_point (%s) is not a "
+                                         "subdirectory of the share root "
+                                         "(%s). Ignoring provided value.\n",
+                                         mount_point,
+                                         handle->conn->connectpath));
+                               mount_point = NULL;
+                       }
+               }
+       }
+
+       if (mount_point != NULL) {
+               config->mount_point = talloc_strdup(config, mount_point);
+               if (config->mount_point == NULL) {
+                       DEBUG(0, (__location__ " talloc_strdup() failed\n"));
+                       return -1;
+               }
+       } else {
+               config->mount_point = shadow_copy2_find_mount_point(config,
+                                                                   handle);
+               if (config->mount_point == NULL) {
+                       DEBUG(0, (__location__ ": shadow_copy2_find_mount_point"
+                                 " failed: %s\n", strerror(errno)));
+                       return -1;
+               }
        }
 
        basedir = lp_parm_const_string(SNUM(handle->conn),