summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2013-05-30 17:26:44 +0200
committerAndrew Bartlett <abartlet@samba.org>2013-10-05 09:21:09 +1300
commited751b9ee49d8e4a319759640321e8b49be4f154 (patch)
treec65910a9ee95a8664b989c862522c674d9885352 /source3
parent1e887fcda097b93a879df726f2b7c2c8d3c4cf54 (diff)
downloadsamba-ed751b9ee49d8e4a319759640321e8b49be4f154.tar.gz
samba-ed751b9ee49d8e4a319759640321e8b49be4f154.tar.bz2
samba-ed751b9ee49d8e4a319759640321e8b49be4f154.zip
shadow_copy2: re-add the basedir option.
Disable basedir if it is not an absolute path or if snapdirseverywhere or crossmountpoints is enabled. Pair-Programmed-With: Björn Baumbach <bb@sernet.de> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/modules/vfs_shadow_copy2.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c
index adcc855320..d584fa92af 100644
--- a/source3/modules/vfs_shadow_copy2.c
+++ b/source3/modules/vfs_shadow_copy2.c
@@ -117,6 +117,8 @@ struct shadow_copy2_config {
bool fixinodes;
char *sort_order;
bool snapdir_absolute;
+ char *basedir;
+ char *mount_point;
};
static bool shadow_copy2_find_slashes(TALLOC_CTX *mem_ctx, const char *str,
@@ -1580,6 +1582,7 @@ static int shadow_copy2_connect(struct vfs_handle_struct *handle,
const char *snapdir;
const char *gmt_format;
const char *sort_order;
+ const char *basedir;
DEBUG(10, (__location__ ": cnum[%u], connectpath[%s]\n",
(unsigned)handle->conn->cnum,
@@ -1646,6 +1649,59 @@ 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;
+ }
+
+ basedir = lp_parm_const_string(SNUM(handle->conn),
+ "shadow", "basedir", NULL);
+
+ if (basedir != NULL) {
+ if (basedir[0] != '/') {
+ DEBUG(1, (__location__ " Warning: 'basedir' is "
+ "relative ('%s'), but it has to be an "
+ "absolute path. Disabling basedir.\n",
+ basedir));
+ } else {
+ char *p;
+ p = strstr(basedir, config->mount_point);
+ if (p != basedir) {
+ DEBUG(1, ("Warning: basedir (%s) is not a "
+ "subdirectory of the share root's "
+ "mount point (%s). "
+ "Disabling basedir\n",
+ basedir, config->mount_point));
+ } else {
+ config->basedir = talloc_strdup(config,
+ basedir);
+ if (config->basedir == NULL) {
+ DEBUG(0, ("talloc_strdup() failed\n"));
+ errno = ENOMEM;
+ return -1;
+ }
+ }
+ }
+ }
+
+ if (config->snapdirseverywhere && config->basedir != NULL) {
+ DEBUG(1, (__location__ " Warning: 'basedir' is incompatible "
+ "with 'snapdirseverywhere'. Disabling basedir.\n"));
+ TALLOC_FREE(config->basedir);
+ }
+
+ if (config->crossmountpoints && config->basedir != NULL) {
+ DEBUG(1, (__location__ " Warning: 'basedir' is incompatible "
+ "with 'crossmountpoints'. Disabling basedir.\n"));
+ TALLOC_FREE(config->basedir);
+ }
+
+ if (config->basedir == NULL) {
+ config->basedir = config->mount_point;
+ }
+
if (config->snapdir[0] == '/') {
config->snapdir_absolute = true;
if (config->snapdirseverywhere == true) {