]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Factor out extract_snapshot_token() from canonicalize_snapshot_path()
authorVolker Lendecke <vl@samba.org>
Thu, 14 Jul 2022 13:13:40 +0000 (15:13 +0200)
committerRalph Boehme <slow@samba.org>
Mon, 25 Jul 2022 12:04:33 +0000 (12:04 +0000)
We'll use this elsewhere soon.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/filename.c
source3/smbd/proto.h

index 58fec6f9113b0eac286f04492d9255f691614eb9..7042503eee156d0dc1152eecd3ae2453ef36b1f4 100644 (file)
@@ -300,6 +300,24 @@ static bool find_snapshot_token(
        return true;
 }
 
+bool extract_snapshot_token(char *fname, NTTIME *twrp)
+{
+       const char *start = NULL;
+       const char *next = NULL;
+       size_t remaining;
+       bool found;
+
+       found = find_snapshot_token(fname, &start, &next, twrp);
+       if (!found) {
+               return false;
+       }
+
+       remaining = strlen(next);
+       memmove(discard_const_p(char, start), next, remaining+1);
+
+       return true;
+}
+
 /*
  * Strip a valid @GMT-token from any incoming filename path,
  * adding any NTTIME encoded in the pathname into the
@@ -318,9 +336,6 @@ NTSTATUS canonicalize_snapshot_path(struct smb_filename *smb_fname,
                                    uint32_t ucf_flags,
                                    NTTIME twrp)
 {
-       const char *start = NULL;
-       const char *next = NULL;
-       size_t remaining;
        bool found;
 
        if (twrp != 0) {
@@ -331,16 +346,11 @@ NTSTATUS canonicalize_snapshot_path(struct smb_filename *smb_fname,
                return NT_STATUS_OK;
        }
 
-       found = find_snapshot_token(
-               smb_fname->base_name, &start, &next, &twrp);
+       found = extract_snapshot_token(smb_fname->base_name, &twrp);
        if (!found) {
                return NT_STATUS_OK;
        }
 
-       remaining = strlen(next);
-
-       memmove(discard_const_p(char, start), next, remaining+1);
-
        if (smb_fname->twrp == 0) {
                smb_fname->twrp = twrp;
        }
index 166317f7965fe4becb2659b3a20b891bbb6c73b6..64653976e22f67db85459a7dca8a9e6605c63d51 100644 (file)
@@ -356,6 +356,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
                      NTTIME twrp,
                      struct smb_filename **smb_fname,
                      uint32_t ucf_flags);
+bool extract_snapshot_token(char *fname, NTTIME *twrp);
 NTSTATUS canonicalize_snapshot_path(struct smb_filename *smb_fname,
                                    uint32_t ucf_flags,
                                    NTTIME twrp);