From dd5d7b88a22ad02fe2f4d48a35570de8f737af4f Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 5 Dec 2017 08:28:28 +0100 Subject: [PATCH] vfs_zfsacl: return synthesized ACL when ZFS return ENOTSUP This allows accessing the ZFS .snapshots directory where ZFS returns ENOTSUP when calling acl(".snapshots"). This also adds a parametric option "zfsacl:expose_snapdir" that can be used to turn this behaviour off. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13175 Signed-off-by: Ralph Boehme --- source3/modules/vfs_zfsacl.c | 50 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c index 0bc4ba6604f..8089678e040 100644 --- a/source3/modules/vfs_zfsacl.c +++ b/source3/modules/vfs_zfsacl.c @@ -233,12 +233,32 @@ static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct *handle, struct SMB4ACL_T *pacl; NTSTATUS status; TALLOC_CTX *frame = talloc_stackframe(); + bool expose; status = zfs_get_nt_acl_common(handle->conn, frame, fsp->fsp_name, &pacl); if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(frame); - return status; + if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { + return status; + } + + expose = lp_parm_bool(conn->params->service, + "zfsacl", "expose_snapdir", true); + if (!expose) { + return status; + } + + status = make_default_filesystem_acl(mem_ctx, + DEFAULT_ACL_POSIX, + fsp->fsp_name->base_name, + &fsp->fsp_name->st, + ppdesc); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + *ppdesc->type |= SEC_DESC_DACL_PROTECTED; + return NT_STATUS_OK; } status = smb_fget_nt_acl_nfs4(fsp, NULL, security_info, mem_ctx, @@ -256,11 +276,37 @@ static NTSTATUS zfsacl_get_nt_acl(struct vfs_handle_struct *handle, struct SMB4ACL_T *pacl; NTSTATUS status; TALLOC_CTX *frame = talloc_stackframe(); + bool expose; status = zfs_get_nt_acl_common(handle->conn, frame, smb_fname, &pacl); if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(frame); - return status; + if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { + return status; + } + + if (!VALID_STAT(smb_fname->st)) { + DBG_ERR("No stat info for [%s]\n", + smb_fname_str_dbg(smb_fname)); + return NT_STATUS_INTERNAL_ERROR; + } + + expose = lp_parm_bool(conn->params->service, + "zfsacl", "expose_snapdir", true); + if (!expose) { + return status; + } + + status = make_default_filesystem_acl(mem_ctx, + DEFAULT_ACL_POSIX, + smb_fname->base_name, + &smb_fname->st, + ppdesc); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + *ppdesc->type |= SEC_DESC_DACL_PROTECTED; + return NT_STATUS_OK; } status = smb_get_nt_acl_nfs4(handle->conn, -- 2.13.6