From 63d2003ecd74b009f484f2af6ad365e754879e13 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 30 May 2017 11:46:49 -0700 Subject: [PATCH] s3: lib: Add new utility function cp_smb_filename_nostream(). Will be needed when we migrate lower-level VFS functions to take an struct smb_filename *, especially the SYS_ACL and XATTR modification modules, as these must ignore a passed-in stream name. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- source3/include/proto.h | 2 ++ source3/lib/filename_util.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/source3/include/proto.h b/source3/include/proto.h index 4e7a431fbb7..121c9eb480d 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1114,6 +1114,8 @@ const char *fsp_str_dbg(const struct files_struct *fsp); const char *fsp_fnum_dbg(const struct files_struct *fsp); struct smb_filename *cp_smb_filename(TALLOC_CTX *mem_ctx, const struct smb_filename *in); +struct smb_filename *cp_smb_filename_nostream(TALLOC_CTX *mem_ctx, + const struct smb_filename *in); bool is_ntfs_stream_smb_fname(const struct smb_filename *smb_fname); bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname); bool is_invalid_windows_ea_name(const char *name); diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c index 3983aaa0eca..8a16bacddbe 100644 --- a/source3/lib/filename_util.c +++ b/source3/lib/filename_util.c @@ -71,6 +71,22 @@ struct smb_filename *synthetic_smb_fname(TALLOC_CTX *mem_ctx, return cp_smb_filename(mem_ctx, &smb_fname_loc); } +/** + * Utility function used by VFS calls that must *NOT* operate + * on a stream filename, only the base_name. + */ +struct smb_filename *cp_smb_filename_nostream(TALLOC_CTX *mem_ctx, + const struct smb_filename *smb_fname_in) +{ + struct smb_filename *smb_fname = cp_smb_filename(mem_ctx, + smb_fname_in); + if (smb_fname == NULL) { + return NULL; + } + TALLOC_FREE(smb_fname->stream_name); + return smb_fname; +} + /** * There are a few legitimate users of this. */ -- 2.47.2