From cf4f966a60c5352f344560963a6a930e0bfbeb03 Mon Sep 17 00:00:00 2001 From: telamonian Date: Tue, 14 Apr 2020 14:09:02 -0400 Subject: [PATCH] fixes #9: remove assumption that everyone ACE exists - also elevates all rights to at least those of everyone by combining masks via bitwise or --- fs/smbfs/smbfs.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/smbfs/smbfs.py b/fs/smbfs/smbfs.py index 01d255e..d8af87c 100644 --- a/fs/smbfs/smbfs.py +++ b/fs/smbfs/smbfs.py @@ -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 @@ -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