From: Jeremy Allison Date: Mon, 24 May 2021 23:58:12 +0000 (-0700) Subject: s3: Add directory_has_default_acl_fsp(). X-Git-Tag: tevent-0.11.0~601 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a87182b2eb8439725a141e182ff2be12d2ad6701;p=thirdparty%2Fsamba.git s3: Add directory_has_default_acl_fsp(). Not yet used. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/file_access.c b/source3/smbd/file_access.c index 3bb4036cfdb..dcdbad2c75e 100644 --- a/source3/smbd/file_access.c +++ b/source3/smbd/file_access.c @@ -190,6 +190,43 @@ bool directory_has_default_acl(connection_struct *conn, return false; } +/**************************************************************************** + Check for an existing default Windows ACL on a directory fsp. +****************************************************************************/ + +bool directory_has_default_acl_fsp(struct files_struct *fsp) +{ + struct security_descriptor *secdesc = NULL; + unsigned int i; + NTSTATUS status; + + status = SMB_VFS_FGET_NT_ACL(fsp, + SECINFO_DACL, + talloc_tos(), + &secdesc); + + if (!NT_STATUS_IS_OK(status) || + secdesc == NULL || + secdesc->dacl == NULL) + { + TALLOC_FREE(secdesc); + return false; + } + + for (i = 0; i < secdesc->dacl->num_aces; i++) { + struct security_ace *psa = &secdesc->dacl->aces[i]; + + if (psa->flags & (SEC_ACE_FLAG_OBJECT_INHERIT| + SEC_ACE_FLAG_CONTAINER_INHERIT)) + { + TALLOC_FREE(secdesc); + return true; + } + } + TALLOC_FREE(secdesc); + return false; +} + /**************************************************************************** Check if setting delete on close is allowed on this fsp. ****************************************************************************/ diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index b29bc5a7155..f8c4db27e87 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -340,6 +340,7 @@ bool can_write_to_file(connection_struct *conn, bool directory_has_default_acl(connection_struct *conn, struct files_struct *dirfsp, struct smb_filename *smb_fname); +bool directory_has_default_acl_fsp(struct files_struct *fsp); NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32_t dosmode); /* The following definitions come from smbd/fileio.c */