The branch, master has been updated
       via  b213082 s3: vfs: snapper: Fix snapper_gmt_strip_snapshot() function 
to strip @GMT token identically to shadow_copy2.c:shadow_copy2_strip_snapshot()
       via  3e3b9be s3: vfs: snapper: Add and use len_before_gmt, calculated as 
(p-name).
       via  abf18f4 s3: vfs: shadow_copy2: Replace all uses of (p-name) with 
len_before_gmt.
      from  2fd20cf ctdb-tests: Validate that TAKE_IP works with IP already on 
an interface

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit b21308252eb409bad6089cc0f09fada0229d33e8
Author: Jeremy Allison <[email protected]>
Date:   Wed Aug 17 10:57:10 2016 -0700

    s3: vfs: snapper: Fix snapper_gmt_strip_snapshot() function to strip @GMT 
token identically to shadow_copy2.c:shadow_copy2_strip_snapshot()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150
    
    Signed-off-by: Jeremy Allison <[email protected]>
    Reviewed-by: Christof Schmitt <[email protected]>
    Reviewed-by: David Disseldorp <[email protected]>
    
    Autobuild-User(master): David Disseldorp <[email protected]>
    Autobuild-Date(master): Thu Aug 18 06:43:02 CEST 2016 on sn-devel-144

commit 3e3b9be948d873696a1ab9c0cb859bd8911165f0
Author: Jeremy Allison <[email protected]>
Date:   Wed Aug 17 10:53:08 2016 -0700

    s3: vfs: snapper: Add and use len_before_gmt, calculated as (p-name).
    
    Make the code closer to the same functionality in 
shadow_copy2.c:shadow_copy2_strip_snapshot().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150
    
    Signed-off-by: Jeremy Allison <[email protected]>
    Reviewed-by: Christof Schmitt <[email protected]>
    Reviewed-by: David Disseldorp <[email protected]>

commit abf18f42dc398f5f17088de87fd0e681fd44ebeb
Author: Jeremy Allison <[email protected]>
Date:   Wed Aug 17 10:49:50 2016 -0700

    s3: vfs: shadow_copy2: Replace all uses of (p-name) with len_before_gmt.
    
    p and name don't change, and we've already calculated this length.
    Part of the effort to make the code inside vfs_snapper.c that does
    the same thing more similar (we can't make these functions identical
    due to the 'snapdir' use case).
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150
    
    Signed-off-by: Jeremy Allison <[email protected]>
    Reviewed-by: Christof Schmitt <[email protected]>
    Reviewed-by: David Disseldorp <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 source3/modules/vfs_shadow_copy2.c |  6 +++---
 source3/modules/vfs_snapper.c      | 30 +++++++++++++++++++++++++-----
 2 files changed, 28 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_shadow_copy2.c 
b/source3/modules/vfs_shadow_copy2.c
index 4ac16d3..2a72740 100644
--- a/source3/modules/vfs_shadow_copy2.c
+++ b/source3/modules/vfs_shadow_copy2.c
@@ -514,7 +514,7 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx,
        q += 1;
 
        rest_len = strlen(q);
-       dst_len = (p-name) + rest_len;
+       dst_len = len_before_gmt + rest_len;
 
        if (priv->config->snapdirseverywhere) {
                char *insert;
@@ -580,10 +580,10 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX 
*mem_ctx,
                        return false;
                }
                if (p > name) {
-                       memcpy(stripped, name, p-name);
+                       memcpy(stripped, name, len_before_gmt);
                }
                if (rest_len > 0) {
-                       memcpy(stripped + (p-name), q, rest_len);
+                       memcpy(stripped + len_before_gmt, q, rest_len);
                }
                stripped[dst_len] = '\0';
                *pstripped = stripped;
diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c
index 8f3c647..5c1821d 100644
--- a/source3/modules/vfs_snapper.c
+++ b/source3/modules/vfs_snapper.c
@@ -1729,6 +1729,7 @@ static bool snapper_gmt_strip_snapshot(TALLOC_CTX 
*mem_ctx,
        char *q;
        char *stripped;
        size_t rest_len, dst_len;
+       ptrdiff_t len_before_gmt;
 
        p = strstr_m(name, "@GMT-");
        if (p == NULL) {
@@ -1737,6 +1738,7 @@ static bool snapper_gmt_strip_snapshot(TALLOC_CTX 
*mem_ctx,
        if ((p > name) && (p[-1] != '/')) {
                goto no_snapshot;
        }
+       len_before_gmt = p - name;
        q = strptime(p, GMT_FORMAT, &tm);
        if (q == NULL) {
                goto no_snapshot;
@@ -1746,9 +1748,23 @@ static bool snapper_gmt_strip_snapshot(TALLOC_CTX 
*mem_ctx,
        if (timestamp == (time_t)-1) {
                goto no_snapshot;
        }
-       if ((p == name) && (q[0] == '\0')) {
+       if (q[0] == '\0') {
+               /*
+                * The name consists of only the GMT token or the GMT
+                * token is at the end of the path. XP seems to send
+                * @GMT- at the end under certain circumstances even
+                * with a path prefix.
+                */
                if (pstripped != NULL) {
-                       stripped = talloc_strdup(mem_ctx, "");
+                       if (len_before_gmt > 0) {
+                               /*
+                                * There is a slash before
+                                * the @GMT-. Remove it.
+                                */
+                               len_before_gmt -= 1;
+                       }
+                       stripped = talloc_strndup(mem_ctx, name,
+                                       len_before_gmt);
                        if (stripped == NULL) {
                                return false;
                        }
@@ -1758,12 +1774,16 @@ static bool snapper_gmt_strip_snapshot(TALLOC_CTX 
*mem_ctx,
                return true;
        }
        if (q[0] != '/') {
+               /*
+                * It is not a complete path component, i.e. the path
+                * component continues after the gmt-token.
+                */
                goto no_snapshot;
        }
        q += 1;
 
        rest_len = strlen(q);
-       dst_len = (p-name) + rest_len;
+       dst_len = len_before_gmt + rest_len;
 
        if (pstripped != NULL) {
                stripped = talloc_array(mem_ctx, char, dst_len+1);
@@ -1772,10 +1792,10 @@ static bool snapper_gmt_strip_snapshot(TALLOC_CTX 
*mem_ctx,
                        return false;
                }
                if (p > name) {
-                       memcpy(stripped, name, p-name);
+                       memcpy(stripped, name, len_before_gmt);
                }
                if (rest_len > 0) {
-                       memcpy(stripped + (p-name), q, rest_len);
+                       memcpy(stripped + len_before_gmt, q, rest_len);
                }
                stripped[dst_len] = '\0';
                *pstripped = stripped;


-- 
Samba Shared Repository

Reply via email to