From: Jeremy Allison Date: Wed, 9 Jun 2021 22:57:38 +0000 (-0700) Subject: s3: VFS: default: Add proc_fd's fallback for vfswrap_fchown(). X-Git-Tag: tevent-0.11.0~438 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f44918e6c83c89936156eb24c982a897c9c45f61;p=thirdparty%2Fsamba.git s3: VFS: default: Add proc_fd's fallback for vfswrap_fchown(). https://bugzilla.samba.org/show_bug.cgi?id=14734 Signed-off-by: Jeremy Allison Reviewed-by: Noel Power Autobuild-User(master): Noel Power Autobuild-Date(master): Thu Jun 10 09:16:22 UTC 2021 on sn-devel-184 --- diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 187b68a78cf..79531f83483 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -2514,7 +2514,31 @@ static int vfswrap_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t ui int result; START_PROFILE(syscall_fchown); - result = fchown(fsp_get_io_fd(fsp), uid, gid); + if (!fsp->fsp_flags.is_pathref) { + result = fchown(fsp_get_io_fd(fsp), uid, gid); + END_PROFILE(syscall_fchown); + return result; + } + + if (fsp->fsp_flags.have_proc_fds) { + int fd = fsp_get_pathref_fd(fsp); + const char *p = NULL; + char buf[PATH_MAX]; + + p = sys_proc_fd_path(fd, buf, sizeof(buf)); + if (p != NULL) { + result = chown(p, uid, gid); + } else { + result = -1; + } + END_PROFILE(syscall_fchown); + return result; + } + + /* + * This is no longer a handle based call. + */ + result = chown(fsp->fsp_name->base_name, uid, gid); END_PROFILE(syscall_fchown); return result; #else