From ce75fbf4e3e59f6be131807e198045485646855f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 18 Mar 2016 21:58:20 -0700 Subject: [PATCH] s3: smbd: Remove many common uses of lp_posix_pathnames(). Check the smb_filename->flags field, or req->posix_pathnames instead, depending on what is available. Signed-off-by: Jeremy Allison Reviewed-by: Uri Simchoni --- source3/lib/filename_util.c | 2 +- source3/modules/vfs_acl_common.c | 4 ++-- source3/modules/vfs_acl_tdb.c | 2 +- source3/modules/vfs_default.c | 2 +- source3/modules/vfs_posix_eadb.c | 2 +- source3/modules/vfs_streams_depot.c | 6 +++--- source3/modules/vfs_streams_xattr.c | 2 +- source3/modules/vfs_xattr_tdb.c | 2 +- source3/smbd/nttrans.c | 2 +- source3/smbd/trans2.c | 22 +++++++++++++++++++--- 10 files changed, 31 insertions(+), 15 deletions(-) diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c index 78bfc7040d8..3983aaa0eca 100644 --- a/source3/lib/filename_util.c +++ b/source3/lib/filename_util.c @@ -233,7 +233,7 @@ bool is_ntfs_stream_smb_fname(const struct smb_filename *smb_fname) SMB_ASSERT(smb_fname->stream_name[0] != '\0'); } - if (lp_posix_pathnames()) { + if (smb_fname->flags & SMB_FILENAME_POSIX_PATH) { return false; } diff --git a/source3/modules/vfs_acl_common.c b/source3/modules/vfs_acl_common.c index d21c16707c8..c907b0fdc95 100644 --- a/source3/modules/vfs_acl_common.c +++ b/source3/modules/vfs_acl_common.c @@ -1138,7 +1138,7 @@ static int chmod_acl_module_common(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname, mode_t mode) { - if (lp_posix_pathnames()) { + if (smb_fname->flags & SMB_FILENAME_POSIX_PATH) { /* Only allow this on POSIX pathnames. */ return SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode); } @@ -1159,7 +1159,7 @@ static int chmod_acl_acl_module_common(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname, mode_t mode) { - if (lp_posix_pathnames()) { + if (smb_fname->flags & SMB_FILENAME_POSIX_PATH) { /* Only allow this on POSIX pathnames. */ return SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode); } diff --git a/source3/modules/vfs_acl_tdb.c b/source3/modules/vfs_acl_tdb.c index 1bc5973622c..eee4d896931 100644 --- a/source3/modules/vfs_acl_tdb.c +++ b/source3/modules/vfs_acl_tdb.c @@ -252,7 +252,7 @@ static int unlink_acl_tdb(vfs_handle_struct *handle, goto out; } - if (lp_posix_pathnames()) { + if (smb_fname_tmp->flags & SMB_FILENAME_POSIX_PATH) { ret = SMB_VFS_LSTAT(handle->conn, smb_fname_tmp); } else { ret = SMB_VFS_STAT(handle->conn, smb_fname_tmp); diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index a7004a0d753..41e443e6ca6 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -2220,7 +2220,7 @@ static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle, smb_fname->base_name); smb_fname_cp.flags = smb_fname->flags; - if (lp_posix_pathnames()) { + if (smb_fname_cp.flags & SMB_FILENAME_POSIX_PATH) { ret = SMB_VFS_LSTAT(handle->conn, &smb_fname_cp); } else { ret = SMB_VFS_STAT(handle->conn, &smb_fname_cp); diff --git a/source3/modules/vfs_posix_eadb.c b/source3/modules/vfs_posix_eadb.c index 1d165298a2e..2c7717a508b 100644 --- a/source3/modules/vfs_posix_eadb.c +++ b/source3/modules/vfs_posix_eadb.c @@ -296,7 +296,7 @@ static int posix_eadb_unlink(vfs_handle_struct *handle, return -1; } - if (lp_posix_pathnames()) { + if (smb_fname->flags & SMB_FILENAME_POSIX_PATH) { ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_tmp); } else { ret = SMB_VFS_NEXT_STAT(handle, smb_fname_tmp); diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index 2b80b9dcf7b..83c9d9743ae 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -714,7 +714,7 @@ static int streams_depot_unlink(vfs_handle_struct *handle, return -1; } - if (lp_posix_pathnames()) { + if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) { ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base); } else { ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base); @@ -776,7 +776,7 @@ static int streams_depot_rmdir(vfs_handle_struct *handle, return -1; } - if (lp_posix_pathnames()) { + if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) { ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base); } else { ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base); @@ -974,7 +974,7 @@ static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle, ret = SMB_VFS_NEXT_FSTAT(handle, fsp, &smb_fname_base->st); } else { - if (lp_posix_pathnames()) { + if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) { ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_base); } else { ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base); diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index b3b800264fb..83134648522 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -252,7 +252,7 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp, return -1; } - if (lp_posix_pathnames()) { + if (smb_fname_base->flags & SMB_FILENAME_POSIX_PATH) { ret = SMB_VFS_LSTAT(handle->conn, smb_fname_base); } else { ret = SMB_VFS_STAT(handle->conn, smb_fname_base); diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c index aac824523b9..aa3bd8279b5 100644 --- a/source3/modules/vfs_xattr_tdb.c +++ b/source3/modules/vfs_xattr_tdb.c @@ -364,7 +364,7 @@ static int xattr_tdb_unlink(vfs_handle_struct *handle, return -1; } - if (lp_posix_pathnames()) { + if (smb_fname_tmp->flags & SMB_FILENAME_POSIX_PATH) { ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname_tmp); } else { ret = SMB_VFS_NEXT_STAT(handle, smb_fname_tmp); diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index be5994a2f89..3a2c35fe7b1 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -1178,7 +1178,7 @@ static void call_nt_transact_create(connection_struct *conn, goto out; } - if (!lp_posix_pathnames() && + if (!req->posix_pathnames && ea_list_has_invalid_name(ea_list)) { /* Realloc the size of parameters and data we will return */ if (flags & EXTENDED_RESPONSE_REQUIRED) { diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index a76b2df70d8..65c2cb079aa 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -371,11 +371,19 @@ static NTSTATUS get_ea_list_from_file_path(TALLOC_CTX *mem_ctx, size_t i, num_names; char **names; struct ea_list *ea_list_head = NULL; + bool posix_pathnames = false; NTSTATUS status; *pea_total_len = 0; *ea_list = NULL; + if (fsp) { + posix_pathnames = + (fsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH); + } else { + posix_pathnames = (smb_fname->flags & SMB_FILENAME_POSIX_PATH); + } + status = get_ea_names_from_file(talloc_tos(), conn, fsp, @@ -404,7 +412,7 @@ static NTSTATUS get_ea_list_from_file_path(TALLOC_CTX *mem_ctx, * Filter out any underlying POSIX EA names * that a Windows client can't handle. */ - if (!lp_posix_pathnames() && + if (!posix_pathnames && is_invalid_windows_ea_name(names[i])) { continue; } @@ -692,11 +700,19 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp, const struct smb_filename *smb_fname, struct ea_list *ea_list) { NTSTATUS status; + bool posix_pathnames = false; if (!lp_ea_support(SNUM(conn))) { return NT_STATUS_EAS_NOT_SUPPORTED; } + if (fsp) { + posix_pathnames = + (fsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH); + } else { + posix_pathnames = (smb_fname->flags & SMB_FILENAME_POSIX_PATH); + } + status = refuse_symlink(conn, fsp, smb_fname); if (!NT_STATUS_IS_OK(status)) { return status; @@ -717,7 +733,7 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp, * we set *any* of them. */ - if (!lp_posix_pathnames() && ea_list_has_invalid_name(ea_list)) { + if (!posix_pathnames && ea_list_has_invalid_name(ea_list)) { return STATUS_INVALID_EA_NAME; } @@ -1297,7 +1313,7 @@ static void call_trans2open(connection_struct *conn, goto out; } - if (!lp_posix_pathnames() && + if (!req->posix_pathnames && ea_list_has_invalid_name(ea_list)) { int param_len = 30; *pparams = (char *)SMB_REALLOC(*pparams, param_len); -- 2.34.1