smbd: pass ucf_flags to canonicalize_snapshot_path()
authorRalph Boehme <slow@samba.org>
Mon, 4 May 2020 11:51:37 +0000 (13:51 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 5 May 2020 19:18:43 +0000 (19:18 +0000)
No change in behaviour. ucf_flags are just now checked *inside*
canonicalize_snapshot_path() instead of the caller.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/filename.c
source3/smbd/proto.h
source3/smbd/trans2.c
source3/torture/cmd_vfs.c

index ca5a7a66282598c33ed898bbe17a28aa8f560320..dd018c0962f55fb2ffde911e5000834882809b4f 100644 (file)
@@ -365,9 +365,10 @@ static NTSTATUS rearrange_snapshot_path(struct smb_filename *smb_fname,
  */
 
 NTSTATUS canonicalize_snapshot_path(struct smb_filename *smb_fname,
+                                   uint32_t ucf_flags,
                                    NTTIME twrp)
 {
-       char *startp = strchr_m(smb_fname->base_name, '@');
+       char *startp = NULL;
        char *endp = NULL;
        char *tmp = NULL;
        struct tm tm;
@@ -379,6 +380,11 @@ NTSTATUS canonicalize_snapshot_path(struct smb_filename *smb_fname,
                smb_fname->twrp = twrp;
        }
 
+       if (!(ucf_flags & UCF_GMT_PATHNAME)) {
+               return NT_STATUS_OK;
+       }
+
+       startp = strchr_m(smb_fname->base_name, '@');
        if (startp == NULL) {
                /* No @ */
                return NT_STATUS_OK;
@@ -510,7 +516,6 @@ struct uc_state {
        bool name_has_wildcard;
        bool posix_pathnames;
        bool allow_wcard_last_component;
-       bool snapshot_path;
        bool done;
 };
 
@@ -958,7 +963,6 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
                .ucf_flags = ucf_flags,
                .posix_pathnames = (ucf_flags & UCF_POSIX_PATHNAMES),
                .allow_wcard_last_component = (ucf_flags & UCF_ALWAYS_ALLOW_WCARD_LCOMP),
-               .snapshot_path = (ucf_flags & UCF_GMT_PATHNAME),
        };
 
        *smb_fname_out = NULL;
@@ -1031,11 +1035,9 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
        }
 
        /* Canonicalize any @GMT- paths. */
-       if (state->snapshot_path) {
-               status = canonicalize_snapshot_path(state->smb_fname, twrp);
-               if (!NT_STATUS_IS_OK(status)) {
-                       goto err;
-               }
+       status = canonicalize_snapshot_path(state->smb_fname, ucf_flags, twrp);
+       if (!NT_STATUS_IS_OK(status)) {
+               goto err;
        }
 
        /*
@@ -1850,7 +1852,9 @@ char *get_original_lcomp(TALLOC_CTX *ctx,
                        TALLOC_FREE(fname);
                        return NULL;
                }
-               status = canonicalize_snapshot_path(smb_fname, 0);
+               status = canonicalize_snapshot_path(smb_fname,
+                                                   ucf_flags,
+                                                   0);
                if (!NT_STATUS_IS_OK(status)) {
                        TALLOC_FREE(fname);
                        TALLOC_FREE(smb_fname);
index 20b5c43f139281781424c3b831b81d596d5f3453..d34a7284796306d1c032deeb5b9d73633edae7c9 100644 (file)
@@ -368,6 +368,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
 NTSTATUS check_name(connection_struct *conn,
                        const struct smb_filename *smb_fname);
 NTSTATUS canonicalize_snapshot_path(struct smb_filename *smb_fname,
+                                   uint32_t ucf_flags,
                                    NTTIME twrp);
 int get_real_filename(connection_struct *conn,
                      struct smb_filename *path,
index 0af680e327f055c2b2ea45adad3d6d7d96098401..e442d2ad4a422042fc65f0eb3a27246a28960227 100644 (file)
@@ -7010,7 +7010,7 @@ static NTSTATUS smb_set_file_unix_link(connection_struct *conn,
        };
 
        /* Removes @GMT tokens if any */
-       status = canonicalize_snapshot_path(&target_fname, 0);
+       status = canonicalize_snapshot_path(&target_fname, UCF_GMT_PATHNAME, 0);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
index ab0e451e77b30a491039afa6d97eb75048a9c2f1..c9de7e7bb157c7e22ff7fa326e20f0c5a58e4a58 100644 (file)
@@ -1172,7 +1172,7 @@ static NTSTATUS cmd_symlink(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc
        };
 
        /* Removes @GMT tokens if any */
-       status = canonicalize_snapshot_path(&target_fname, 0);
+       status = canonicalize_snapshot_path(&target_fname, UCF_GMT_PATHNAME, 0);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }