libcli/security: correct access check and maximum access calculation for Owner Rights...
authorRalph Boehme <slow@samba.org>
Fri, 1 Mar 2019 17:20:35 +0000 (18:20 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 4 Mar 2019 18:11:16 +0000 (18:11 +0000)
commit9722f75757c0e38c7f42c7cc310d56aa6eaf6392
tree9c21414c63a875263ecf903867473726ab5ca0f8
parentfadc4c1bc5fcc3b2d9daea44ef8daf8a8ae0fbe2
libcli/security: correct access check and maximum access calculation for Owner Rights ACEs

We basically must process the Owner Rights ACEs as any other ACE wrt to the
order of adding granted permissions and checking denied permissions. According
to MS-DTYP 2.5.3.2 Owner Rights ACEs must be evaluated in the main loop over
the ACEs in an ACL and the corresponding access_mask must be directly applied
to bits_remaining. We currently defer this to after the loop over the ACEs in
ACL, this is wrong.

We just have to do some initial magic to determine if an ACL contains and
Owner Rights ACEs, and in case it doesn't we grant SEC_STD_WRITE_DAC |
SEC_STD_READ_CONTROL at the *beginning*. MS-DTYP:

-- the owner of an object is always granted READ_CONTROL and WRITE_DAC.
CALL SidInToken(Token, SecurityDescriptor.Owner, PrincipalSelfSubst)
IF SidInToken returns True THEN
   IF DACL does not contain ACEs from object owner THEN
       Remove READ_CONTROL and WRITE_DAC from RemainingAccess
       Set GrantedAccess to GrantedAccess or READ_CONTROL or WRITE_OWNER
   END IF
END IF

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13812

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
libcli/security/access_check.c
selftest/knownfail.d/smb2.acls [deleted file]