From: Ralph Boehme Date: Tue, 29 Sep 2020 09:11:53 +0000 (+0200) Subject: vfs_default: support pathref fd's in vfswrap_fsetxattr() X-Git-Tag: samba-4.14.0rc1~394 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9b3c80f8c1cfef77b9e376682065796690cd8e3d;p=thirdparty%2Fsamba.git vfs_default: support pathref fd's in vfswrap_fsetxattr() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 11112fcb962..c8325cbe633 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -3659,7 +3659,28 @@ static int vfswrap_setxattr(struct vfs_handle_struct *handle, static int vfswrap_fsetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags) { - return fsetxattr(fsp_get_io_fd(fsp), name, value, size, flags); + int fd = fsp_get_pathref_fd(fsp); + + if (!fsp->fsp_flags.is_pathref) { + return fsetxattr(fd, name, value, size, flags); + } + + if (fsp->fsp_flags.have_proc_fds) { + const char *p = NULL; + char buf[PATH_MAX]; + + p = sys_proc_fd_path(fd, buf, sizeof(buf)); + if (p == NULL) { + return -1; + } + + return setxattr(p, name, value, size, flags); + } + + /* + * This is no longer a handle based call. + */ + return setxattr(fsp->fsp_name->base_name, name, value, size, flags); } static bool vfswrap_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp)