The branch, master has been updated
       via  9c19532 s3-shadow-copy2: Protect against already converted names
       via  1d48827 s3-shadow-copy2: Add more debugs
       via  87cad88 s3-shadow-copy2: Fix incorrect case submounts
       via  b053d4b s3-shadow-copy2: Remove TODO and fix comments
       via  16a6181 s3-shadow-copy2: Fix dir/@GMT-2012.10.15-13.48.43 form of 
paths
       via  68c7b33 s3-shadow-copy2: Add extreme debug output to 
shadow_copy2_strip_snapshot
       via  064dd03 dbwrap: Print wait times with full precision
      from  b0f5fa4 smb2: Fix smb2_lease_state

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


- Log -----------------------------------------------------------------
commit 9c195321345846195e465158f88dad5fd7699389
Author: Volker Lendecke <[email protected]>
Date:   Thu Oct 18 15:24:39 2012 +0200

    s3-shadow-copy2: Protect against already converted names
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Christof Schmitt <[email protected]>
    
    Autobuild-User(master): Volker Lendecke <[email protected]>
    Autobuild-Date(master): Fri Jun 27 09:03:53 CEST 2014 on sn-devel-104

commit 1d488270a116b3140de1355c1492aa2652a57e08
Author: Volker Lendecke <[email protected]>
Date:   Wed Oct 17 12:11:37 2012 +0200

    s3-shadow-copy2: Add more debugs
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Christof Schmitt <[email protected]>

commit 87cad882308a00330bdcba67bf048cdb0f7ab9d9
Author: Volker Lendecke <[email protected]>
Date:   Wed Oct 17 12:08:26 2012 +0200

    s3-shadow-copy2: Fix incorrect case submounts
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Christof Schmitt <[email protected]>

commit b053d4b3f9fd26f1ea4d81d3a4461a6f74bf7686
Author: Christof Schmitt <[email protected]>
Date:   Thu Jun 26 12:43:03 2014 -0700

    s3-shadow-copy2: Remove TODO and fix comments
    
    The patch "s3-shadow-copy2: Fix dir/@GMT-2012.10.15-13.48.43 form of
    paths" takes care of a case marked as TODO, remove it and adjust the
    comments accordingly.
    
    Signed-off-by: Christof Schmitt <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

commit 16a6181289b719baeae7fae7fe0ba746fd5d41a6
Author: Volker Lendecke <[email protected]>
Date:   Mon Oct 15 18:16:44 2012 +0200

    s3-shadow-copy2: Fix dir/@GMT-2012.10.15-13.48.43 form of paths
    
    The previous clause in shadow_copy2_strip_snapshot would only handle @GMT-
    at the end of a pathname if it was the *only* pathname component. XP
    seems to send @GMT- at the end under certain circumstances even with a
    path prefix.
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Christof Schmitt <[email protected]>

commit 68c7b339ccb02305a27b1192222537074efa0085
Author: Volker Lendecke <[email protected]>
Date:   Mon Oct 15 18:13:33 2012 +0200

    s3-shadow-copy2: Add extreme debug output to shadow_copy2_strip_snapshot
    
    This is sooo hairy to debug when things go wrong :-(
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Christof Schmitt <[email protected]>

commit 064dd03223deb86e5baaadfc2f9b72dde829d995
Author: Volker Lendecke <[email protected]>
Date:   Thu Mar 6 07:27:36 2014 +0100

    dbwrap: Print wait times with full precision
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Christof Schmitt <[email protected]>

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

Summary of changes:
 source3/lib/dbwrap/dbwrap_ctdb.c   |    6 +-
 source3/modules/vfs_shadow_copy2.c |   80 +++++++++++++++++++++++++++--------
 2 files changed, 64 insertions(+), 22 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index ca33c8f..0b30d9f 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -1168,15 +1168,15 @@ again:
 
                DEBUG(0, ("db_ctdb_fetch_locked for %s key %s, chain %d "
                          "needed %d attempts, %d milliseconds, "
-                         "chainlock: %d ms, CTDB %d ms\n",
+                         "chainlock: %f ms, CTDB %f ms\n",
                          tdb_name(ctx->wtdb->tdb),
                          hex_encode_talloc(talloc_tos(),
                                            (unsigned char *)key.dptr,
                                            key.dsize),
                          chain,
                          migrate_attempts, duration_msecs,
-                         (int) chainlock_time * 1000,
-                         (int) ctdb_time * 1000));
+                         chainlock_time * 1000.0,
+                         ctdb_time * 1000.0));
        }
 
        GetTimeOfDay(&crec->lock_time);
diff --git a/source3/modules/vfs_shadow_copy2.c 
b/source3/modules/vfs_shadow_copy2.c
index 30eaaa4..439df5d 100644
--- a/source3/modules/vfs_shadow_copy2.c
+++ b/source3/modules/vfs_shadow_copy2.c
@@ -235,6 +235,9 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx,
        char *stripped;
        size_t rest_len, dst_len;
        struct shadow_copy2_config *config;
+       const char *snapdir;
+       ssize_t snapdirlen;
+       ptrdiff_t len_before_gmt;
 
        SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
                                return false);
@@ -243,25 +246,60 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX 
*mem_ctx,
 
        p = strstr_m(name, "@GMT-");
        if (p == NULL) {
+               DEBUG(11, ("@GMT not found\n"));
                goto no_snapshot;
        }
        if ((p > name) && (p[-1] != '/')) {
                /* the GMT-token does not start a path-component */
+               DEBUG(10, ("not at start, p=%p, name=%p, p[-1]=%d\n",
+                          p, name, (int)p[-1]));
                goto no_snapshot;
        }
+
+       /*
+        * Figure out whether we got an already converted string. One
+        * case where this happens is in a smb2 create call with the
+        * mxac create blob set. We do the get_acl call on
+        * fsp->fsp_name, which is already converted. We are converted
+        * if we got a file name of the form ".snapshots/@GMT-",
+        * i.e. ".snapshots/" precedes "p".
+        */
+
+       snapdir = lp_parm_const_string(SNUM(handle->conn), "shadow", "snapdir",
+                                      ".snapshots");
+       snapdirlen = strlen(snapdir);
+       len_before_gmt = p - name;
+
+       if ((len_before_gmt >= (snapdirlen + 1)) && (p[-1] == '/')) {
+               const char *parent_snapdir = p - (snapdirlen+1);
+
+               DEBUG(10, ("parent_snapdir = %s\n", parent_snapdir));
+
+               if (strncmp(parent_snapdir, snapdir, snapdirlen) == 0) {
+                       DEBUG(10, ("name=%s is already converted\n", name));
+                       goto no_snapshot;
+               }
+       }
        q = strptime(p, GMT_FORMAT, &tm);
        if (q == NULL) {
+               DEBUG(10, ("strptime failed\n"));
                goto no_snapshot;
        }
        tm.tm_isdst = -1;
        timestamp = timegm(&tm);
        if (timestamp == (time_t)-1) {
+               DEBUG(10, ("timestamp==-1\n"));
                goto no_snapshot;
        }
-       if ((p == name) && (q[0] == '\0')) {
-               /* the name consists of only the GMT token */
+       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, "");
+                       stripped = talloc_strndup(mem_ctx, name, p - name);
                        if (stripped == NULL) {
                                return false;
                        }
@@ -272,13 +310,10 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX 
*mem_ctx,
        }
        if (q[0] != '/') {
                /*
-                * The GMT token is either at the end of the path
-                * or it is not a complete path component, i.e. the
-                * path component continues after the gmt-token.
-                *
-                * TODO: Is this correct? Or would the GMT tag as the
-                * last component be a valid input?
+                * It is not a complete path component, i.e. the path
+                * component continues after the gmt-token.
                 */
+               DEBUG(10, ("q[0] = %d\n", (int)q[0]));
                goto no_snapshot;
        }
        q += 1;
@@ -301,6 +336,8 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx,
                           "insert string '%s'\n", name, insert));
 
                have_insert = (strstr(name, insert+1) != NULL);
+               DEBUG(10, ("have_insert=%d, name=%s, insert+1=%s\n",
+                          (int)have_insert, name, insert+1));
                if (have_insert) {
                        DEBUG(10, (__location__ ": insert string '%s' found in "
                                   "path '%s' found in snapdirseverywhere mode "
@@ -463,8 +500,12 @@ static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx,
                /* never reached ... */
        }
 
-       path = talloc_asprintf(mem_ctx, "%s/%s", handle->conn->connectpath,
-                              name);
+       if (name[0] == 0) {
+               path = talloc_strdup(mem_ctx, handle->conn->connectpath);
+       } else {
+               path = talloc_asprintf(
+                       mem_ctx, "%s/%s", handle->conn->connectpath, name);
+       }
        if (path == NULL) {
                errno = ENOMEM;
                goto fail;
@@ -1660,29 +1701,30 @@ static int shadow_copy2_get_real_filename(struct 
vfs_handle_struct *handle,
        int saved_errno;
        char *conv;
 
+       DEBUG(10, ("shadow_copy2_get_real_filename called for path=[%s], "
+                  "name=[%s]\n", path, name));
+
        if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, path,
                                         &timestamp, &stripped)) {
+               DEBUG(10, ("shadow_copy2_strip_snapshot failed\n"));
                return -1;
        }
        if (timestamp == 0) {
+               DEBUG(10, ("timestamp == 0\n"));
                return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
                                                      mem_ctx, found_name);
        }
-       if (stripped[0] == '\0') {
-               *found_name = talloc_strdup(mem_ctx, name);
-               if (*found_name == NULL) {
-                       errno = ENOMEM;
-                       return -1;
-               }
-               return 0;
-       }
        conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
        TALLOC_FREE(stripped);
        if (conv == NULL) {
+               DEBUG(10, ("shadow_copy2_convert failed\n"));
                return -1;
        }
+       DEBUG(10, ("Calling NEXT_GET_REAL_FILE_NAME for conv=[%s], "
+                  "name=[%s]\n", conv, name));
        ret = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, conv, name,
                                             mem_ctx, found_name);
+       DEBUG(10, ("NEXT_REAL_FILE_NAME returned %d\n", (int)ret));
        saved_errno = errno;
        TALLOC_FREE(conv);
        errno = saved_errno;


-- 
Samba Shared Repository

Reply via email to