Skip to content

Commit

Permalink
Remove assumption that everyone ACE exists (#11)
Browse files Browse the repository at this point in the history
- also elevates all rights to at least those of everyone by combining
  masks via bitwise or
  • Loading branch information
telamonian committed May 13, 2020
1 parent bb99bde commit 2df1e4c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions fs/smbfs/smbfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def _make_access_from_sd(cls, sd):
# * `everyone` (used for UNIX `others` mode)
# * `owner` (used for UNIX `user` mode, falls back to `everyone`)
# * `group` (used for UNIX `group` mode, falls back to `everyone`)
other_ace = next(ace for ace in sd.dacl.aces
if str(ace.sid).startswith(smb.security_descriptors.SID_EVERYONE))
other_ace = next((ace for ace in sd.dacl.aces
if str(ace.sid).startswith(smb.security_descriptors.SID_EVERYONE)), None)
owner_ace = next((ace for ace in sd.dacl.aces
if str(ace.sid).startswith(str(sd.owner))), other_ace)
group_ace = next((ace for ace in sd.dacl.aces
Expand All @@ -170,10 +170,11 @@ def _make_access_from_sd(cls, sd):
}

# Defines the mask used for each mode
other_mask = other_ace.mask if other_ace is not None else 0x0
modes = {
'u': owner_ace.mask,
'g': group_ace.mask,
'o': other_ace.mask,
'u': (owner_ace.mask if owner_ace is not None else 0x0) | other_mask,
'g': (group_ace.mask if group_ace is not None else 0x0) | other_mask,
'o': other_mask,
}

# Create the permissions from a permission list
Expand Down

0 comments on commit 2df1e4c

Please sign in to comment.