From 4bfd27b077f0932c82cfe702bd4ba6628f75a526 Mon Sep 17 00:00:00 2001 From: Uri Simchoni Date: Thu, 2 Mar 2017 08:39:56 +0200 Subject: [PATCH] smbd: remove coupling between get_ea_names_from_file() and "ea support" The "ea support" configuration variable determines whether smbd should attempt to manipulate extended attributes via SMB protocol. It does not pertain to the underlying storage and its support for extended attributes. get_ea_names_from_file() is being used also by vfs_streams_xattr - a module which has nothing to do with client-visible extended attributes. As such, vfs_streams_xattr should be able to operate irrespective of the value of "ea support". This patch moves the check for ea support to the callers. Signed-off-by: Uri Simchoni Reviewed-by: Ralph Boehme --- source3/smbd/nttrans.c | 30 ++++++++++++++++++------------ source3/smbd/trans2.c | 8 ++++---- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 5f122a95e24..a5fc62536e7 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -688,16 +688,19 @@ void reply_ntcreate_and_X(struct smb_request *req) p += 8; if (flags & EXTENDED_RESPONSE_REQUIRED) { uint16_t file_status = (NO_EAS|NO_SUBSTREAMS|NO_REPARSETAG); - size_t num_names = 0; unsigned int num_streams = 0; struct stream_struct *streams = NULL; - /* Do we have any EA's ? */ - status = get_ea_names_from_file(ctx, conn, fsp, - smb_fname, NULL, &num_names); - if (NT_STATUS_IS_OK(status) && num_names) { - file_status &= ~NO_EAS; + if (lp_ea_support(SNUM(conn))) { + size_t num_names = 0; + /* Do we have any EA's ? */ + status = get_ea_names_from_file( + ctx, conn, fsp, smb_fname, NULL, &num_names); + if (NT_STATUS_IS_OK(status) && num_names) { + file_status &= ~NO_EAS; + } } + status = vfs_streaminfo(conn, NULL, smb_fname, ctx, &num_streams, &streams); /* There is always one stream, ::$DATA. */ @@ -1334,16 +1337,19 @@ static void call_nt_transact_create(connection_struct *conn, p += 8; if (flags & EXTENDED_RESPONSE_REQUIRED) { uint16_t file_status = (NO_EAS|NO_SUBSTREAMS|NO_REPARSETAG); - size_t num_names = 0; unsigned int num_streams = 0; struct stream_struct *streams = NULL; - /* Do we have any EA's ? */ - status = get_ea_names_from_file(ctx, conn, fsp, - smb_fname, NULL, &num_names); - if (NT_STATUS_IS_OK(status) && num_names) { - file_status &= ~NO_EAS; + if (lp_ea_support(SNUM(conn))) { + size_t num_names = 0; + /* Do we have any EA's ? */ + status = get_ea_names_from_file( + ctx, conn, fsp, smb_fname, NULL, &num_names); + if (NT_STATUS_IS_OK(status) && num_names) { + file_status &= ~NO_EAS; + } } + status = vfs_streaminfo(conn, NULL, smb_fname, ctx, &num_streams, &streams); /* There is always one stream, ::$DATA. */ diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index dc6dc7179bd..b6bf93f946c 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -262,10 +262,6 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, } *pnum_names = 0; - if (!lp_ea_support(SNUM(conn))) { - return NT_STATUS_OK; - } - status = refuse_symlink(conn, fsp, smb_fname); if (!NT_STATUS_IS_OK(status)) { /* @@ -397,6 +393,10 @@ static NTSTATUS get_ea_list_from_file_path(TALLOC_CTX *mem_ctx, *pea_total_len = 0; *ea_list = NULL; + if (!lp_ea_support(SNUM(conn))) { + return NT_STATUS_OK; + } + if (fsp) { posix_pathnames = (fsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH); -- 2.34.1