s3: VFS: default: Add proc_fd's fallback for vfswrap_fchown().
authorJeremy Allison <jra@samba.org>
Wed, 9 Jun 2021 22:57:38 +0000 (15:57 -0700)
committerNoel Power <npower@samba.org>
Thu, 10 Jun 2021 09:16:22 +0000 (09:16 +0000)
https://bugzilla.samba.org/show_bug.cgi?id=14734

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Thu Jun 10 09:16:22 UTC 2021 on sn-devel-184

source3/modules/vfs_default.c

index 187b68a78cf8141e375442460d08f573da52eeb1..79531f83483efde35e0dcb7f68bde37b05d582bd 100644 (file)
@@ -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