From c9889c194aa61c20ff91baa14ef4f2d37d292e86 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 1 Oct 2020 15:21:45 +0200 Subject: vfs_posixacl: support pathref fd's in posixacl_sys_acl_set_fd() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- source3/modules/vfs_posixacl.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'source3/modules/vfs_posixacl.c') diff --git a/source3/modules/vfs_posixacl.c b/source3/modules/vfs_posixacl.c index 2ab2cc026be..cca4dd22b60 100644 --- a/source3/modules/vfs_posixacl.c +++ b/source3/modules/vfs_posixacl.c @@ -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; } -- cgit v1.2.1