]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_posixacl: support pathref fd's in posixacl_sys_acl_get_fd()
authorRalph Boehme <slow@samba.org>
Thu, 1 Oct 2020 13:20:56 +0000 (15:20 +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 219acc6bd4d374831efd0c27ebc7952d7feb25f6..2ab2cc026bed03f2b11df2daf78440a0a0d6817d 100644 (file)
@@ -69,8 +69,27 @@ SMB_ACL_T posixacl_sys_acl_get_fd(vfs_handle_struct *handle,
                                  files_struct *fsp, TALLOC_CTX *mem_ctx)
 {
        struct smb_acl_t *result;
-       acl_t acl = acl_get_fd(fsp_get_io_fd(fsp));
+       acl_t acl = NULL;
 
+       if (!fsp->fsp_flags.is_pathref) {
+               acl = acl_get_fd(fsp_get_io_fd(fsp));
+       } else if (fsp->fsp_flags.have_proc_fds) {
+               int fd = fsp_get_pathref_fd(fsp);
+               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 NULL;
+               }
+
+               acl = acl_get_file(proc_fd_path, ACL_TYPE_ACCESS);
+       } else {
+               /*
+                * This is no longer a handle based call.
+                */
+               acl = acl_get_file(fsp->fsp_name->base_name, ACL_TYPE_ACCESS);
+       }
        if (acl == NULL) {
                return NULL;
        }