[PATCH] two corner case fixes to shadow_copy2

Michael Adam obnox at samba.org
Tue Apr 11 10:53:25 UTC 2017


Hi all,

we are hitting a regression with Samba 4.6 and the
combination of the shadow_copy2 and glusterfs vfs
modules.

It seems to have been introduced by the patches of
https://bugzilla.samba.org/show_bug.cgi?id=12531

It's my fault that I did not notice the patches
and the request for review at that time... :-)

I still need to do more analysis and testing,
but it seems that there are two corner cases
that are at least hit when using the glusterfs
vfs module that mimicks the share root to "/":

1) make_relative_path does not treat the
   case of cwd == "/" correctly.

2) shadow_copy2_strip_snapshot does not treat the
   corner case where the name only consists of
   "/" followed by the @GMT-token correctly.

These corner cases are not coverered by our
test cases, and as I said, I need to do more
testing (e.g. if this is all), but attached find
two patches that fix the above corner cases
in a rahter obvious way.

Thanks for review...

Michael
-------------- next part --------------
From 76e15576e3144ca87bca3dee0ddba9f60ba04fed Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 11 Apr 2017 12:03:20 +0200
Subject: [PATCH 1/2] s3:vfs:shadow_copy2: fix the corner case if cwd=/ in
 make_relative_path

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source3/modules/vfs_shadow_copy2.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c
index f3ec8b6..550c953 100644
--- a/source3/modules/vfs_shadow_copy2.c
+++ b/source3/modules/vfs_shadow_copy2.c
@@ -444,7 +444,10 @@ 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') {
+	if (cwd_len != 1 &&
+	    abs_path[cwd_len] != '/' &&
+	    abs_path[cwd_len] != '\0')
+	{
 		return false;
 	}
 	if (abs_path[cwd_len] == '/') {
-- 
2.9.3


From 6b095855ecc3038a03278e81f53398bc7c35a8bf Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 11 Apr 2017 12:03:52 +0200
Subject: [PATCH 2/2] s3:vfs:shadow_copy2: fix corner case of "/@GMT-token" in
 shadow_copy2_strip_snapshot

Signed-off-by: Michael Adam <obnox at samba.org>
---
 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 550c953..d06e321 100644
--- a/source3/modules/vfs_shadow_copy2.c
+++ b/source3/modules/vfs_shadow_copy2.c
@@ -670,10 +670,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.9.3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20170411/53c5e08c/signature.sig>


More information about the samba-technical mailing list