vfs_posixacl: support pathref fd's in posixacl_sys_acl_set_fd()
authorRalph Boehme <slow@samba.org>
Thu, 1 Oct 2020 13:21:45 +0000 (15:21 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 16 Dec 2020 09:08:30 +0000 (09:08 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_posixacl.c

index 2ab2cc026bed03f2b11df2daf78440a0a0d6817d..cca4dd22b60855ece763714b6191a25c7b0dfb75 100644 (file)
@@ -141,10 +141,32 @@ int posixacl_sys_acl_set_fd(vfs_handle_struct *handle,
 {
        int res;
        acl_t acl = smb_acl_to_posix(theacl);
+       int fd = fsp_get_pathref_fd(fsp);
+
        if (acl == NULL) {
                return -1;
        }
-       res =  acl_set_fd(fsp_get_io_fd(fsp), acl);
+
+       if (!fsp->fsp_flags.is_pathref) {
+               res = acl_set_fd(fd, acl);
+       } else if (fsp->fsp_flags.have_proc_fds) {
+               const char *proc_fd_path = NULL;
+               char buf[PATH_MAX];
+
+               proc_fd_path = sys_proc_fd_path(fd, buf, sizeof(buf));
+               if (proc_fd_path == NULL) {
+                       return -1;
+               }
+               res = acl_set_file(proc_fd_path, ACL_TYPE_ACCESS, acl);
+       } else {
+               /*
+                * This is no longer a handle based call.
+                */
+               res = acl_set_file(fsp->fsp_name->base_name,
+                                  ACL_TYPE_ACCESS,
+                                  acl);
+       }
+
        acl_free(acl);
        return res;
 }