From: Ralph Boehme Date: Thu, 1 Oct 2020 13:22:18 +0000 (+0200) Subject: smbd/posix_acls: support pathref fd's in posix_sys_acl_blob_get_fd() X-Git-Tag: samba-4.14.0rc1~390 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=879d8a3be9f660384f49657b8214168c4b62aee5;p=thirdparty%2Fsamba.git smbd/posix_acls: support pathref fd's in posix_sys_acl_blob_get_fd() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index 862dda35495..fb137f29350 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -4693,26 +4693,49 @@ int posix_sys_acl_blob_get_fd(vfs_handle_struct *handle, { SMB_STRUCT_STAT sbuf; TALLOC_CTX *frame; - struct smb_acl_wrapper acl_wrapper; + struct smb_acl_wrapper acl_wrapper = { 0 }; + int fd = fsp_get_pathref_fd(fsp); + struct smb_filename fname; int ret; - /* This ensures that we also consider the default ACL */ - if (fsp->fsp_flags.is_directory || fsp_get_io_fd(fsp) == -1) { - return posix_sys_acl_blob_get_file(handle, - fsp->fsp_name, - mem_ctx, - blob_description, - blob); + 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; + } + + fname = (struct smb_filename) { + .base_name = discard_const_p(char, proc_fd_path), + }; + } else { + /* + * This is no longer a handle based call. + */ + + fname = (struct smb_filename) { + .base_name = fsp->fsp_name->base_name, + }; } - frame = talloc_stackframe(); - acl_wrapper.default_acl = NULL; + frame = talloc_stackframe(); - acl_wrapper.access_acl = smb_vfs_call_sys_acl_get_file(handle, - fsp->fsp_name, + acl_wrapper.access_acl = smb_vfs_call_sys_acl_get_file( + handle, + &fname, SMB_ACL_TYPE_ACCESS, frame); + if (fsp->fsp_flags.is_directory) { + acl_wrapper.default_acl = smb_vfs_call_sys_acl_get_file( + handle, + &fname, + SMB_ACL_TYPE_DEFAULT, + frame); + } + ret = smb_vfs_call_fstat(handle, fsp, &sbuf); if (ret == -1) { TALLOC_FREE(frame);