From 279604d53755d2b89873fa3a87cba6b1137ba092 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 11 Apr 2017 11:18:30 +0200 Subject: [PATCH 1/3] s3:vfs:shadow_copy2: fix quoting in debug messages Signed-off-by: Michael Adam Reviewed-by: Jeremy Allison (cherry picked from commit fffd611fdc558ab428c8a21cf1e68feaf1f6f469) --- source3/modules/vfs_shadow_copy2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 2afc5954e7d..f3ec8b61ab5 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -684,7 +684,7 @@ static bool shadow_copy2_strip_snapshot_internal(TALLOC_CTX *mem_ctx, if (make_relative_path(priv->shadow_cwd, stripped) == false) { DEBUG(10, (__location__ ": path '%s' " - "doesn't start with cwd '%s\n", + "doesn't start with cwd '%s'\n", stripped, priv->shadow_cwd)); ret = false; errno = ENOENT; @@ -726,7 +726,7 @@ static bool shadow_copy2_strip_snapshot_internal(TALLOC_CTX *mem_ctx, if (make_relative_path(priv->shadow_cwd, stripped) == false) { DEBUG(10, (__location__ ": path '%s' " - "doesn't start with cwd '%s\n", + "doesn't start with cwd '%s'\n", stripped, priv->shadow_cwd)); ret = false; errno = ENOENT; -- 2.12.2.816.g2cccc81164-goog From c2b2febc98a8fa9d1e1ae30ea27d2a8e85164a0a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 11 Apr 2017 12:03:20 +0200 Subject: [PATCH 2/3] s3:vfs:shadow_copy2: fix the corner case if cwd=/ in make_relative_path Signed-off-by: Michael Adam Reviewed-by: Jeremy Allison (cherry picked from commit 16c89835cf07caa2082b586666095deba38ef962) --- source3/modules/vfs_shadow_copy2.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index f3ec8b61ab5..83be84e50a8 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -444,7 +444,11 @@ static bool make_relative_path(const char *cwd, char *abs_path) if (memcmp(abs_path, cwd, cwd_len) != 0) { return false; } - if (abs_path[cwd_len] != '/' && abs_path[cwd_len] != '\0') { + /* The cwd_len != 1 case is for $cwd == '/' */ + if (cwd_len != 1 && + abs_path[cwd_len] != '/' && + abs_path[cwd_len] != '\0') + { return false; } if (abs_path[cwd_len] == '/') { -- 2.12.2.816.g2cccc81164-goog From 9fbfb8e1cc0559842017a6692350593835f23df5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 11 Apr 2017 12:03:52 +0200 Subject: [PATCH 3/3] s3:vfs:shadow_copy2: fix corner case of "/@GMT-token" in shadow_copy2_strip_snapshot Signed-off-by: Michael Adam Reviewed-by: Jeremy Allison (cherry picked from commit 26661218b3d3f0d4ee89039727bc110e972c2851) --- source3/modules/vfs_shadow_copy2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 83be84e50a8..7cacac81c1c 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -671,10 +671,11 @@ static bool shadow_copy2_strip_snapshot_internal(TALLOC_CTX *mem_ctx, * with a path prefix. */ if (pstripped != NULL) { - if (len_before_gmt > 0) { + if (len_before_gmt > 1) { /* - * There is a slash before - * the @GMT-. Remove it. + * There is a path (and not only a slash) + * before the @GMT-. Remove the trailing + * slash character. */ len_before_gmt -= 1; } -- 2.12.2.816.g2cccc81164-goog