From: Ralph Boehme Date: Sun, 4 Oct 2020 12:48:48 +0000 (+0200) Subject: smbd: use fsp_get_pathref_fd() for "internal" xattr functions X-Git-Tag: samba-4.14.0rc1~413 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5648662b2f2b91133d3ec8ece69a32955348fa23;p=thirdparty%2Fsamba.git smbd: use fsp_get_pathref_fd() for "internal" xattr functions 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/modules/vfs_acl_xattr.c b/source3/modules/vfs_acl_xattr.c index aaba8cda62d..2f286ed97f7 100644 --- a/source3/modules/vfs_acl_xattr.c +++ b/source3/modules/vfs_acl_xattr.c @@ -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 { diff --git a/source3/modules/vfs_nfs4acl_xattr.c b/source3/modules/vfs_nfs4acl_xattr.c index cfc3b151a50..2a8db673708 100644 --- a/source3/modules/vfs_nfs4acl_xattr.c +++ b/source3/modules/vfs_nfs4acl_xattr.c @@ -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 { diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index d9514b22df3..862dda35495 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -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 {