diff options
author | Ralph Boehme <slow@samba.org> | 2019-09-26 10:05:40 -0700 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2019-10-16 19:25:13 +0000 |
commit | 8f44a25e2a630a28d908392603eae5987ec4e91e (patch) | |
tree | e81ff6e0d1ad33dd65d3fe6b8e086b5ccaef1e09 | |
parent | c48a5c6b8c995595a519e9069e3efbe24291f190 (diff) | |
download | samba-8f44a25e2a630a28d908392603eae5987ec4e91e.tar.gz |
s3:lib: add is_named_stream()
Add a new utility functions that checks whether a struct smb_filename points to
a real named stream, excluding the default stream "::$DATA".
foo -> false
foo::$DATA -> false
foo:bar -> true
foo:bar:$DATA -> true
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14137
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 091e3fdab61217251de1cf5111f070ff295d1649)
-rw-r--r-- | source3/include/proto.h | 1 | ||||
-rw-r--r-- | source3/lib/filename_util.c | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index ad6f3bbf9c3..cb8890d340b 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -985,6 +985,7 @@ 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_named_stream(const struct smb_filename *smb_fname); bool is_invalid_windows_ea_name(const char *name); bool ea_list_has_invalid_name(struct ea_list *ea_list); bool split_stream_filename(TALLOC_CTX *ctx, diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c index 2917481c8bf..66c07001eba 100644 --- a/source3/lib/filename_util.c +++ b/source3/lib/filename_util.c @@ -268,6 +268,32 @@ bool is_ntfs_stream_smb_fname(const struct smb_filename *smb_fname) } /**************************************************************************** + Simple check to determine if a smb_fname is pointing to a normal file or + a named stream that is not the default stream "::$DATA". + + foo -> false + foo::$DATA -> false + foo:bar -> true + foo:bar:$DATA -> true + + ***************************************************************************/ + +bool is_named_stream(const struct smb_filename *smb_fname) +{ + assert_valid_stream_smb_fname(smb_fname); + + if (smb_fname->stream_name == NULL) { + return false; + } + + if (strequal_m(smb_fname->stream_name, "::$DATA")) { + return false; + } + + return true; +} + +/**************************************************************************** Returns true if the filename's stream == "::$DATA" ***************************************************************************/ bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname) |