From: Jeremy Allison Date: Fri, 2 Jul 2021 20:35:37 +0000 (-0700) Subject: s3: lib: In ad_read_meta(), allow use of SMB_VFS_FGETXATTR() as well as SMB_VFS_GETXA... X-Git-Tag: tevent-0.11.0~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53e0494958d0e444c19ef103231d8eba05b3a95e;p=thirdparty%2Fsamba.git s3: lib: In ad_read_meta(), allow use of SMB_VFS_FGETXATTR() as well as SMB_VFS_GETXATTR(). Eventually we will guarantee a valid smb_fname->fsp here and will remove SMB_VFS_GETXATTR(). Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/source3/lib/adouble.c b/source3/lib/adouble.c index 3788943941e..876791fd1d5 100644 --- a/source3/lib/adouble.c +++ b/source3/lib/adouble.c @@ -2037,12 +2037,27 @@ static ssize_t ad_read_meta(vfs_handle_struct *handle, int rc = 0; ssize_t ealen; bool ok; + struct files_struct *fsp = smb_fname->fsp; DEBUG(10, ("reading meta xattr for %s\n", smb_fname->base_name)); - ealen = SMB_VFS_GETXATTR(handle->conn, smb_fname, - AFPINFO_EA_NETATALK, ad->ad_data, - AD_DATASZ_XATTR); + if (fsp != NULL && fsp->base_fsp != NULL) { + fsp = fsp->base_fsp; + } + + if (fsp != NULL) { + ealen = SMB_VFS_FGETXATTR(fsp, + AFPINFO_EA_NETATALK, + ad->ad_data, + AD_DATASZ_XATTR); + } else { + ealen = SMB_VFS_GETXATTR(handle->conn, + smb_fname, + AFPINFO_EA_NETATALK, + ad->ad_data, + AD_DATASZ_XATTR); + } + if (ealen == -1) { switch (errno) { case ENOATTR: @@ -2096,9 +2111,9 @@ exit: if (rc != 0) { ealen = -1; if (errno == EINVAL) { - if (smb_fname->fsp != NULL) { + if (fsp != NULL) { become_root(); - (void)SMB_VFS_FREMOVEXATTR(smb_fname->fsp, + (void)SMB_VFS_FREMOVEXATTR(fsp, AFPINFO_EA_NETATALK); unbecome_root(); }