diff options
author | Ralph Boehme <slow@samba.org> | 2020-05-04 13:51:37 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2020-05-05 19:18:43 +0000 |
commit | f689f3cb2284470f2e56ae4512ff20079e610fa1 (patch) | |
tree | ac6810a510d9974824e1ad67743b842b3dd8f5a2 | |
parent | 6e364c545384c5da4a0f0f0536c40394aa2e2a97 (diff) | |
download | samba-f689f3cb2284470f2e56ae4512ff20079e610fa1.tar.gz |
smbd: pass ucf_flags to canonicalize_snapshot_path()
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>
-rw-r--r-- | source3/smbd/filename.c | 22 | ||||
-rw-r--r-- | source3/smbd/proto.h | 1 | ||||
-rw-r--r-- | source3/smbd/trans2.c | 2 | ||||
-rw-r--r-- | source3/torture/cmd_vfs.c | 2 |
4 files changed, 16 insertions, 11 deletions
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index ca5a7a66282..dd018c0962f 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -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); diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 20b5c43f139..d34a7284796 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -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, diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 0af680e327f..e442d2ad4a4 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -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; } diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index ab0e451e77b..c9de7e7bb15 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -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; } |