s3: smbd: Remove many common uses of lp_posix_pathnames().
authorJeremy Allison <jra@samba.org>
Sat, 19 Mar 2016 04:58:20 +0000 (21:58 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 24 Mar 2016 21:57:16 +0000 (22:57 +0100)
Check the smb_filename->flags field, or req->posix_pathnames
instead, depending on what is available.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
source3/lib/filename_util.c
source3/modules/vfs_acl_common.c
source3/modules/vfs_acl_tdb.c
source3/modules/vfs_default.c
source3/modules/vfs_posix_eadb.c
source3/modules/vfs_streams_depot.c
source3/modules/vfs_streams_xattr.c
source3/modules/vfs_xattr_tdb.c
source3/smbd/nttrans.c
source3/smbd/trans2.c

index 78bfc70..3983aaa 100644 (file)
@@ -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;
        }
 
index d21c167..c907b0f 100644 (file)
@@ -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);
        }
index 1bc5973..eee4d89 100644 (file)
@@ -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);
index a7004a0..41e443e 100644 (file)
@@ -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);
index 1d16529..2c7717a 100644 (file)
@@ -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);
index 2b80b9d..83c9d97 100644 (file)
@@ -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);
index b3b8002..8313464 100644 (file)
@@ -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);
index aac8245..aa3bd82 100644 (file)
@@ -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);
index be5994a..3a2c35f 100644 (file)
@@ -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) {
index a76b2df..65c2cb0 100644 (file)
@@ -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);