From 2d5a3af4bc44d13877a26fa1857b3ceafe138de8 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 31 May 2013 16:36:33 +0200 Subject: shadow_copy2: introduce "shadow:mountpoint" option Possiblity to explicitly set the share's mount point. This is useful mainly for debugging and testing purposes. Signed-off-by: Michael Adam Reviewed-by: Andrew Bartlett --- source3/modules/vfs_shadow_copy2.c | 43 +++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index d584fa92af..afe2ff4638 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -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), -- cgit