From aacb3618c10ec65056011c1366c1b82cba29cc89 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 11 Feb 2022 09:59:16 +0100 Subject: [PATCH] smbd: Use fsp_is_alternate_stream() where an fsp is available Make it clear that being an alternate data stream handle is much more a fsp property than a file name property. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/modules/vfs_default.c | 6 +++--- source3/modules/vfs_fruit.c | 2 +- source3/modules/vfs_gpfs.c | 2 +- source3/modules/vfs_streams_xattr.c | 2 +- source3/modules/vfs_virusfilter.c | 2 +- source3/smbd/durable.c | 2 +- source3/smbd/file_access.c | 2 +- source3/smbd/nttrans.c | 2 +- source3/smbd/smb2_write.c | 3 +-- source3/smbd/trans2.c | 4 ++-- 10 files changed, 13 insertions(+), 14 deletions(-) diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index f3aec6c2bff..49a73ab97f6 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -2234,8 +2234,8 @@ static NTSTATUS vfswrap_offload_copy_file_range(struct tevent_req *req) return NT_STATUS_MORE_PROCESSING_REQUIRED; } - if (is_named_stream(state->src_fsp->fsp_name) || - is_named_stream(state->dst_fsp->fsp_name)) + if (fsp_is_alternate_stream(state->src_fsp) || + fsp_is_alternate_stream(state->dst_fsp)) { return NT_STATUS_MORE_PROCESSING_REQUIRED; } @@ -2761,7 +2761,7 @@ static int vfswrap_fntimes(vfs_handle_struct *handle, START_PROFILE(syscall_fntimes); - if (is_named_stream(fsp->fsp_name)) { + if (fsp_is_alternate_stream(fsp)) { errno = ENOENT; goto out; } diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 15491e52af6..e84c4c98d37 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1870,7 +1870,7 @@ static int fruit_close(vfs_handle_struct *handle, DBG_DEBUG("Path [%s] fd [%d]\n", smb_fname_str_dbg(fsp->fsp_name), fd); - if (!is_named_stream(fsp->fsp_name)) { + if (!fsp_is_alternate_stream(fsp)) { return SMB_VFS_NEXT_CLOSE(handle, fsp); } diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index f6f162b3b57..52517ee0084 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -178,7 +178,7 @@ static int vfs_gpfs_filesystem_sharemode(vfs_handle_struct *handle, * fd, so lacking a distinct fd for the stream we have to skip * set_gpfs_sharemode for stream. */ - if (is_named_stream(fsp->fsp_name)) { + if (fsp_is_alternate_stream(fsp)) { DBG_NOTICE("Not requesting GPFS sharemode on stream: %s/%s\n", fsp->conn->connectpath, fsp_str_dbg(fsp)); diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 0f745c63fbd..156a1d65133 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -464,7 +464,7 @@ static int streams_xattr_close(vfs_handle_struct *handle, DBG_DEBUG("streams_xattr_close called [%s] fd [%d]\n", smb_fname_str_dbg(fsp->fsp_name), fd); - if (!is_named_stream(fsp->fsp_name)) { + if (!fsp_is_alternate_stream(fsp)) { return SMB_VFS_NEXT_CLOSE(handle, fsp); } diff --git a/source3/modules/vfs_virusfilter.c b/source3/modules/vfs_virusfilter.c index d1554967ad1..cbb93161a8a 100644 --- a/source3/modules/vfs_virusfilter.c +++ b/source3/modules/vfs_virusfilter.c @@ -1459,7 +1459,7 @@ static int virusfilter_vfs_close( return close_result; } - if (is_named_stream(fsp->fsp_name)) { + if (fsp_is_alternate_stream(fsp)) { if (config->scan_on_open && fsp->fsp_flags.modified) { if (config->cache) { DBG_DEBUG("Removing cache entry (if existent)" diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index a49bca6fd61..e5dc86a5a7d 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -79,7 +79,7 @@ NTSTATUS vfs_default_durable_cookie(struct files_struct *fsp, return NT_STATUS_NOT_SUPPORTED; } - if (is_ntfs_stream_smb_fname(fsp->fsp_name)) { + if (fsp_is_alternate_stream(fsp)) { /* * We do not support durable handles * on streams for now. diff --git a/source3/smbd/file_access.c b/source3/smbd/file_access.c index 9193c650316..e3c8a1e2b67 100644 --- a/source3/smbd/file_access.c +++ b/source3/smbd/file_access.c @@ -228,7 +228,7 @@ NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32_t dosmode) /* Don't allow delete on close for non-empty directories. */ if (fsp->fsp_flags.is_directory) { - SMB_ASSERT(!is_ntfs_stream_smb_fname(fsp->fsp_name)); + SMB_ASSERT(!fsp_is_alternate_stream(fsp)); /* Or the root of a share. */ if (ISDOT(fsp->fsp_name->base_name)) { diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 546639e9b78..af7a49646e9 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -452,7 +452,7 @@ static NTSTATUS get_relative_fid_filename(connection_struct *conn, return NT_STATUS_INVALID_HANDLE; } - if (is_ntfs_stream_smb_fname(dir_fsp->fsp_name)) { + if (fsp_is_alternate_stream(dir_fsp)) { return NT_STATUS_INVALID_HANDLE; } diff --git a/source3/smbd/smb2_write.c b/source3/smbd/smb2_write.c index e4067f83c2e..ff99127b067 100644 --- a/source3/smbd/smb2_write.c +++ b/source3/smbd/smb2_write.c @@ -193,8 +193,7 @@ static NTSTATUS smb2_write_complete_internal(struct tevent_req *req, files_struct *fsp = state->fsp; if (nwritten == -1) { - if (err == EOVERFLOW && - is_ntfs_stream_smb_fname(fsp->fsp_name)) { + if (err == EOVERFLOW && fsp_is_alternate_stream(fsp)) { status = NT_STATUS_FILE_SYSTEM_LIMITATION; } else { status = map_nt_error_from_unix(err); diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 9e3f5406450..9dc0d648cd8 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -427,7 +427,7 @@ static NTSTATUS get_ea_list_from_fsp(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } - if (is_ntfs_stream_smb_fname(fsp->fsp_name)) { + if (fsp_is_alternate_stream(fsp)) { return NT_STATUS_INVALID_PARAMETER; } @@ -759,7 +759,7 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp, } /* Setting EAs on streams isn't supported. */ - if (is_ntfs_stream_smb_fname(fsp->fsp_name)) { + if (fsp_is_alternate_stream(fsp)) { return NT_STATUS_INVALID_PARAMETER; } -- 2.34.1