Skip to content

Commit ff0e004

Browse files
committed
python/ntacls.py: only allow allow and deny ACEs in setntacl()
Commit 27dd0af introduced a regression. Before that commit we included only SEC_ACE_TYPE_ACCESS_ALLOWED(0) as 'not type & SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT' filtered out SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT(5), but also SEC_ACE_TYPE_ACCESS_DENIED and SEC_ACE_TYPE_ACCESS_DENIED_OBJECT. After that commit we started to include SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT, which is wrong. It was also always wrong to exclude SEC_ACE_TYPE_ACCESS_DENIED(1). So now we make it explicit that we only include SEC_ACE_TYPE_ACCESS_ALLOWED and SEC_ACE_TYPE_ACCESS_DENIED. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14927 Pair-Programmed-With: Stefan Metzmacher <[email protected]> Signed-off-by: Ralph Boehme <[email protected]> Signed-off-by: Stefan Metzmacher <[email protected]>
1 parent 301c36d commit ff0e004

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

python/samba/ntacls.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,17 +300,33 @@ def dsacl2fsacl(dssddl, sid, as_sddl=True):
300300
fdescr.type = ref.type
301301
fdescr.revision = ref.revision
302302
aces = ref.dacl.aces
303+
303304
for i in range(0, len(aces)):
304305
ace = aces[i]
305-
if ace.type in (security.SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT,
306-
security.SEC_ACE_TYPE_ACCESS_ALLOWED) and str(ace.trustee) != security.SID_BUILTIN_PREW2K:
307-
# if fdescr.type & security.SEC_DESC_DACL_AUTO_INHERITED:
308-
ace.flags = ace.flags | security.SEC_ACE_FLAG_OBJECT_INHERIT | security.SEC_ACE_FLAG_CONTAINER_INHERIT
309-
if str(ace.trustee) == security.SID_CREATOR_OWNER:
310-
# For Creator/Owner the IO flag is set as this ACE has only a sense for child objects
311-
ace.flags = ace.flags | security.SEC_ACE_FLAG_INHERIT_ONLY
312-
ace.access_mask = ldapmask2filemask(ace.access_mask)
313-
fdescr.dacl_add(ace)
306+
307+
# Only apply allowed and deny ACEs, as they are the only ones
308+
# we can map to filesystem aces.
309+
#
310+
# In future we may need to include resource based aces...
311+
allowed_ace_types = [
312+
security.SEC_ACE_TYPE_ACCESS_ALLOWED,
313+
security.SEC_ACE_TYPE_ACCESS_DENIED,
314+
]
315+
if not ace.type in allowed_ace_types:
316+
continue
317+
318+
# Don't add the allow for SID_BUILTIN_PREW2K as in
319+
# gp_create_gpt_security_descriptor()
320+
if str(ace.trustee) == security.SID_BUILTIN_PREW2K:
321+
continue
322+
323+
ace.flags = ace.flags | security.SEC_ACE_FLAG_OBJECT_INHERIT | security.SEC_ACE_FLAG_CONTAINER_INHERIT
324+
if str(ace.trustee) == security.SID_CREATOR_OWNER:
325+
# For Creator/Owner the IO flag is set as this ACE has only a sense for child objects
326+
ace.flags = ace.flags | security.SEC_ACE_FLAG_INHERIT_ONLY
327+
328+
ace.access_mask = ldapmask2filemask(ace.access_mask)
329+
fdescr.dacl_add(ace)
314330

315331
if not as_sddl:
316332
return fdescr

selftest/knownfail.d/python-ntacls

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)