The branch, master has been updated
       via  89828c64c9a libsmb: Simplify clistr_is_previous_version_path()
       via  833cb4cb812 libsmb: Slightly simplify cli_smb2_create_fnum_send()
       via  c64c8af6d4b libsmb: Use clistr_smb2_extract_snapshot_token() in 
cli_smb2_create_fnum_send()
       via  157a79f0ca4 s3: lib: Add new clistr_smb2_extract_snapshot_token() 
function.
       via  fdc6449a3fd s3: smbd: Make extract_snapshot_token() a wrapper for 
extract_snapshot_token_internal().
       via  96d68c6b8ae libsmb: Make a r/w copy of fname in 
cli_smb2_create_fnum_send()
      from  9189bd9c9c1 build: Convert winexe to use enabled= in wscript

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


- Log -----------------------------------------------------------------
commit 89828c64c9a8114bb5f596bc007a7c126e803d80
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Dec 15 19:14:48 2022 +0100

    libsmb: Simplify clistr_is_previous_version_path()
    
    Nobody looks at the out params anymore
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Volker Lendecke <v...@samba.org>
    Autobuild-Date(master): Fri Dec 16 08:42:18 UTC 2022 on sn-devel-184

commit 833cb4cb8126dcbee914551bcd2e852cec67786c
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Dec 15 19:10:09 2022 +0100

    libsmb: Slightly simplify cli_smb2_create_fnum_send()
    
    We can now write to fname directly.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit c64c8af6d4b121b0fa7ebe13b5c7c28ee9cc8053
Author: Jeremy Allison <j...@samba.org>
Date:   Thu Dec 15 13:32:35 2022 -0800

    libsmb: Use clistr_smb2_extract_snapshot_token() in 
cli_smb2_create_fnum_send()
    
    Now that fname is writable, we can avoid a bit of complexity with
    clistr_smb2_extract_snapshot_token()
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Signed-off-by: Jeremy Allison <j...@samba.org>

commit 157a79f0ca45a19db0826a7b49ab0582e8191a68
Author: Jeremy Allison <j...@samba.org>
Date:   Thu Dec 15 13:26:49 2022 -0800

    s3: lib: Add new clistr_smb2_extract_snapshot_token() function.
    
    Strips @GMT from client pathnames for SMB2 (uses '\\' separator).
    
    Signed-off-by: Jeremy Allison <j...@samba.org>
    Reviewed-by: Volker Lendecke <v...@samba.org>

commit fdc6449a3fdfb342184d6a30f22d8cf9cf708841
Author: Jeremy Allison <j...@samba.org>
Date:   Thu Dec 15 13:24:12 2022 -0800

    s3: smbd: Make extract_snapshot_token() a wrapper for 
extract_snapshot_token_internal().
    
    Allows us to pass in path separator from a new function without
    changing existing calling code.
    
    Signed-off-by: Jeremy Allison <j...@samba.org>
    Reviewed-by: Volker Lendecke <v...@samba.org>

commit 96d68c6b8aef33d6a227f3b52c241140cc0e8246
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Dec 15 18:54:58 2022 +0100

    libsmb: Make a r/w copy of fname in cli_smb2_create_fnum_send()
    
    We're messing with this in 2 places in this routine and have to make a
    copy in both places. Make this writable, so we don't have to make a
    copy further down.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

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

Summary of changes:
 source3/lib/util_path.c        | 34 ++++++++++++++-------------------
 source3/lib/util_path.h        |  6 ++----
 source3/libsmb/cli_smb2_fnum.c | 43 ++++++++++++++----------------------------
 source3/libsmb/clifile.c       | 28 +++++++++++++--------------
 source3/libsmb/clilist.c       |  4 ++--
 5 files changed, 46 insertions(+), 69 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/util_path.c b/source3/lib/util_path.c
index 5a94b391dd6..9c9c6eb5807 100644
--- a/source3/lib/util_path.c
+++ b/source3/lib/util_path.c
@@ -260,10 +260,7 @@ static bool find_snapshot_token(
        return true;
 }
 
-bool clistr_is_previous_version_path(const char *path,
-                                    const char **startp,
-                                    const char **endp,
-                                    NTTIME *ptwrp)
+bool clistr_is_previous_version_path(const char *path)
 {
        const char *start = NULL;
        const char *next = NULL;
@@ -271,30 +268,17 @@ bool clistr_is_previous_version_path(const char *path,
        bool ok;
 
        ok = find_snapshot_token(path, '\\', &start, &next, &twrp);
-       if (!ok) {
-               return false;
-       }
-
-       if (startp != NULL) {
-               *startp = start;
-       }
-       if (endp != NULL) {
-               *endp = next;
-       }
-       if (ptwrp != NULL) {
-               *ptwrp = twrp;
-       }
-       return true;
+       return ok;
 }
 
-bool extract_snapshot_token(char *fname, NTTIME *twrp)
+static bool extract_snapshot_token_internal(char *fname, NTTIME *twrp, char 
sep)
 {
        const char *start = NULL;
        const char *next = NULL;
        size_t remaining;
        bool found;
 
-       found = find_snapshot_token(fname, '/', &start, &next, twrp);
+       found = find_snapshot_token(fname, sep, &start, &next, twrp);
        if (!found) {
                return false;
        }
@@ -305,6 +289,16 @@ bool extract_snapshot_token(char *fname, NTTIME *twrp)
        return true;
 }
 
+bool extract_snapshot_token(char *fname, NTTIME *twrp)
+{
+       return extract_snapshot_token_internal(fname, twrp, '/');
+}
+
+bool clistr_smb2_extract_snapshot_token(char *fname, NTTIME *twrp)
+{
+       return extract_snapshot_token_internal(fname, twrp, '\\');
+}
+
 /*
  * Take two absolute paths, figure out if "subdir" is a proper
  * subdirectory of "parent". Return the component relative to the
diff --git a/source3/lib/util_path.h b/source3/lib/util_path.h
index 5b0a1f13e38..9dcc1dd23ca 100644
--- a/source3/lib/util_path.h
+++ b/source3/lib/util_path.h
@@ -45,10 +45,8 @@ char *state_path(TALLOC_CTX *mem_ctx, const char *name);
 char *cache_path(TALLOC_CTX *mem_ctx, const char *name);
 char *canonicalize_absolute_path(TALLOC_CTX *ctx, const char *abs_path);
 bool extract_snapshot_token(char *fname, NTTIME *twrp);
-bool clistr_is_previous_version_path(const char *path,
-                                    const char **startp,
-                                    const char **endp,
-                                    NTTIME *ptwrp);
+bool clistr_smb2_extract_snapshot_token(char *fname, NTTIME *twrp);
+bool clistr_is_previous_version_path(const char *path);
 bool subdir_of(const char *parent,
               size_t parent_len,
               const char *subdir,
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index bb99201bb61..734c24531d9 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -158,9 +158,9 @@ static uint8_t flags_to_smb2_oplock(uint32_t create_flags)
  if this hasn't already been done.
 ***************************************************************/
 
-static const char *smb2_dfs_share_path(TALLOC_CTX *ctx,
-                                      struct cli_state *cli,
-                                      const char *path)
+static char *smb2_dfs_share_path(TALLOC_CTX *ctx,
+                                struct cli_state *cli,
+                                char *path)
 {
        bool is_dfs = smbXcli_conn_dfs_supported(cli->conn) &&
                        smbXcli_tcon_is_dfs_share(cli->smb2.tcon);
@@ -210,7 +210,7 @@ struct tevent_req *cli_smb2_create_fnum_send(
        TALLOC_CTX *mem_ctx,
        struct tevent_context *ev,
        struct cli_state *cli,
-       const char *fname,
+       const char *fname_in,
        uint32_t create_flags,
        uint32_t impersonation_level,
        uint32_t desired_access,
@@ -222,9 +222,9 @@ struct tevent_req *cli_smb2_create_fnum_send(
 {
        struct tevent_req *req, *subreq;
        struct cli_smb2_create_fnum_state *state;
+       char *fname = NULL;
        size_t fname_len = 0;
-       const char *startp = NULL;
-       const char *endp = NULL;
+       bool have_twrp;
        NTTIME ntt;
        NTSTATUS status;
 
@@ -235,28 +235,18 @@ struct tevent_req *cli_smb2_create_fnum_send(
        }
        state->cli = cli;
 
+       fname = talloc_strdup(state, fname_in);
+       if (tevent_req_nomem(fname, req)) {
+               return tevent_req_post(req, ev);
+       }
+
        if (cli->backup_intent) {
                create_options |= FILE_OPEN_FOR_BACKUP_INTENT;
        }
 
        /* Check for @GMT- paths. Remove the @GMT and turn into TWrp if so. */
-       fname_len = strlen(fname);
-       if (clistr_is_previous_version_path(fname, &startp, &endp, &ntt)) {
-               size_t len_before_gmt = startp - fname;
-               size_t len_after_gmt = fname + fname_len - endp;
-
-               char *new_fname = talloc_array(state, char,
-                               len_before_gmt + len_after_gmt + 1);
-
-               if (tevent_req_nomem(new_fname, req)) {
-                       return tevent_req_post(req, ev);
-               }
-
-               memcpy(new_fname, fname, len_before_gmt);
-               memcpy(new_fname + len_before_gmt, endp, len_after_gmt + 1);
-               fname = new_fname;
-               fname_len = len_before_gmt + len_after_gmt;
-
+       have_twrp = clistr_smb2_extract_snapshot_token(fname, &ntt);
+       if (have_twrp) {
                status = smb2_create_blob_add(
                        state,
                        &state->in_cblobs,
@@ -298,12 +288,7 @@ struct tevent_req *cli_smb2_create_fnum_send(
 
        /* Or end in a '\' */
        if (fname_len > 0 && fname[fname_len-1] == '\\') {
-               char *new_fname = talloc_strdup(state, fname);
-               if (tevent_req_nomem(new_fname, req)) {
-                       return tevent_req_post(req, ev);
-               }
-               new_fname[fname_len-1] = '\0';
-               fname = new_fname;
+               fname[fname_len-1] = '\0';
        }
 
        subreq = smb2cli_create_send(state, ev,
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 91bb1095643..13619c74209 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -79,7 +79,7 @@ struct tevent_req *cli_setpathinfo_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (clistr_is_previous_version_path(path, NULL, NULL, NULL) &&
+       if (clistr_is_previous_version_path(path) &&
                        !INFO_LEVEL_IS_UNIX(level)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
@@ -1332,7 +1332,7 @@ static struct tevent_req *cli_cifs_rename_send(TALLOC_CTX 
*mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (clistr_is_previous_version_path(fname_src, NULL, NULL, NULL)) {
+       if (clistr_is_previous_version_path(fname_src)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
 
@@ -1558,7 +1558,7 @@ static struct tevent_req 
*cli_ntrename_internal_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (clistr_is_previous_version_path(fname_src, NULL, NULL, NULL)) {
+       if (clistr_is_previous_version_path(fname_src)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
 
@@ -2009,7 +2009,7 @@ struct tevent_req *cli_unlink_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (clistr_is_previous_version_path(fname, NULL, NULL, NULL)) {
+       if (clistr_is_previous_version_path(fname)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
 
@@ -2141,7 +2141,7 @@ struct tevent_req *cli_mkdir_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (clistr_is_previous_version_path(dname, NULL, NULL, NULL)) {
+       if (clistr_is_previous_version_path(dname)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
 
@@ -2280,7 +2280,7 @@ struct tevent_req *cli_rmdir_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (clistr_is_previous_version_path(dname, NULL, NULL, NULL)) {
+       if (clistr_is_previous_version_path(dname)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
 
@@ -2549,7 +2549,7 @@ static struct tevent_req *cli_ntcreate1_send(TALLOC_CTX 
*mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (clistr_is_previous_version_path(fname, NULL, NULL, NULL)) {
+       if (clistr_is_previous_version_path(fname)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
 
@@ -2896,7 +2896,7 @@ struct tevent_req *cli_nttrans_create_send(TALLOC_CTX 
*mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (clistr_is_previous_version_path(fname, NULL, NULL, NULL)) {
+       if (clistr_is_previous_version_path(fname)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
 
@@ -3136,7 +3136,7 @@ struct tevent_req *cli_openx_create(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (clistr_is_previous_version_path(fname, NULL, NULL, NULL)) {
+       if (clistr_is_previous_version_path(fname)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
 
@@ -4363,7 +4363,7 @@ struct tevent_req *cli_getatr_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (clistr_is_previous_version_path(fname, NULL, NULL, NULL)) {
+       if (clistr_is_previous_version_path(fname)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
 
@@ -4676,7 +4676,7 @@ struct tevent_req *cli_setatr_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (clistr_is_previous_version_path(fname, NULL, NULL, NULL)) {
+       if (clistr_is_previous_version_path(fname)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
 
@@ -4836,7 +4836,7 @@ struct tevent_req *cli_chkpath_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (clistr_is_previous_version_path(fname, NULL, NULL, NULL)) {
+       if (clistr_is_previous_version_path(fname)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
 
@@ -5182,7 +5182,7 @@ struct tevent_req *cli_ctemp_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (clistr_is_previous_version_path(path, NULL, NULL, NULL)) {
+       if (clistr_is_previous_version_path(path)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
 
@@ -6574,7 +6574,7 @@ struct tevent_req *cli_qpathinfo_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (clistr_is_previous_version_path(fname, NULL, NULL, NULL) &&
+       if (clistr_is_previous_version_path(fname) &&
                        !INFO_LEVEL_IS_UNIX(level)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c
index c41ba93cd25..903c5d22777 100644
--- a/source3/libsmb/clilist.c
+++ b/source3/libsmb/clilist.c
@@ -700,7 +700,7 @@ static struct tevent_req *cli_list_trans_send(TALLOC_CTX 
*mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       if (clistr_is_previous_version_path(state->mask, NULL, NULL, NULL)) {
+       if (clistr_is_previous_version_path(state->mask)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
 
@@ -901,7 +901,7 @@ static void cli_list_trans_done(struct tevent_req *subreq)
        }
        param_len = talloc_get_size(state->param);
 
-       if (clistr_is_previous_version_path(state->mask, NULL, NULL, NULL)) {
+       if (clistr_is_previous_version_path(state->mask)) {
                additional_flags2 = FLAGS2_REPARSE_PATH;
        }
 


-- 
Samba Shared Repository

Reply via email to