]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: use fsp_get_pathref_fd() for "internal" xattr functions
authorRalph Boehme <slow@samba.org>
Sun, 4 Oct 2020 12:48:48 +0000 (14:48 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 16 Dec 2020 09:08:30 +0000 (09:08 +0000)
We're using xattr data storage for internal reasons in these places, so in all
places it's safe to use a possibly root opened fd.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_acl_xattr.c
source3/modules/vfs_nfs4acl_xattr.c
source3/smbd/posix_acls.c

index aaba8cda62d5257446acea7c666202aba9fcbdb1..2f286ed97f77218d8f14d009c5295992fd6d89d5 100644 (file)
@@ -46,7 +46,7 @@ static ssize_t getxattr_do(vfs_handle_struct *handle,
        int saved_errno = 0;
 
        become_root();
-       if (fsp && fsp->fh->fd != -1) {
+       if (fsp && fsp_get_pathref_fd(fsp) != -1) {
                sizeret = SMB_VFS_FGETXATTR(fsp, xattr_name, val, size);
        } else {
                sizeret = SMB_VFS_GETXATTR(handle->conn, smb_fname,
@@ -196,7 +196,7 @@ static NTSTATUS store_acl_blob_fsp(vfs_handle_struct *handle,
                  (unsigned int)pblob->length, fsp_str_dbg(fsp)));
 
        become_root();
-       if (fsp->fh->fd != -1) {
+       if (fsp_get_pathref_fd(fsp) != -1) {
                ret = SMB_VFS_FSETXATTR(fsp, XATTR_NTACL_NAME,
                        pblob->data, pblob->length, 0);
        } else {
index cfc3b151a505b07ece4a43184783396ee52f692e..2a8db6737087b3cd8de7efeb6e46774be50987a9 100644 (file)
@@ -133,7 +133,7 @@ static NTSTATUS nfs4acl_get_blob(struct vfs_handle_struct *handle,
                        return NT_STATUS_NO_MEMORY;
                }
 
-               if (fsp != NULL && fsp->fh->fd != -1) {
+               if (fsp != NULL && fsp_get_pathref_fd(fsp) != -1) {
                        length = SMB_VFS_NEXT_FGETXATTR(handle,
                                                        fsp,
                                                        config->xattr_name,
@@ -335,7 +335,7 @@ static bool nfs4acl_smb4acl_set_fn(vfs_handle_struct *handle,
                return false;
        }
 
-       if (fsp->fh->fd != -1) {
+       if (fsp_get_pathref_fd(fsp) != -1) {
                ret = SMB_VFS_NEXT_FSETXATTR(handle, fsp, config->xattr_name,
                                             blob.data, blob.length, 0);
        } else {
index d9514b22df361697229194bae2c7ed990aa6ad35..862dda35495d6a758ecd13f01d983528ba71b662 100644 (file)
@@ -271,7 +271,7 @@ static void store_inheritance_attributes(files_struct *fsp,
        pai_buf = create_pai_buf_v2(file_ace_list, dir_ace_list,
                                sd_type, &store_size);
 
-       if (fsp->fh->fd != -1) {
+       if (fsp_get_pathref_fd(fsp) != -1) {
                ret = SMB_VFS_FSETXATTR(fsp, SAMBA_POSIX_INHERITANCE_EA_NAME,
                                pai_buf, store_size, 0);
        } else {
@@ -624,7 +624,7 @@ static struct pai_val *fload_inherited_info(files_struct *fsp)
        }
 
        do {
-               if (fsp->fh->fd != -1) {
+               if (fsp_get_pathref_fd(fsp) != -1) {
                        ret = SMB_VFS_FGETXATTR(fsp, SAMBA_POSIX_INHERITANCE_EA_NAME,
                                        pai_buf, pai_buf_size);
                } else {