diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2016-08-19 16:50:04 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2016-08-19 16:50:15 +0200 |
commit | a8716448cecc1c09f1ee8896d1b148c5bdda8fca (patch) | |
tree | 9520f5a9c1b9cc3541cbf260d5e5f04bae3d3844 /winsup/cygwin/sec_acl.cc | |
parent | 3e8f833df0689701b6188b975a9af7a061e910ee (diff) | |
download | cygnal-a8716448cecc1c09f1ee8896d1b148c5bdda8fca.tar.gz cygnal-a8716448cecc1c09f1ee8896d1b148c5bdda8fca.tar.bz2 cygnal-a8716448cecc1c09f1ee8896d1b148c5bdda8fca.zip |
Simplify "Windows-standard-like" permissions
Commit 97d0449 left a bit to be desired. First, the fact that any
new-style ACL couldn't be "standard ACL" anymore was very much over
the top. On one hand Admins and SYSTEM ACEs are not supposed to be
masked, but on the other hand we *must* create the CLASS_OBJ
because otherwise we don't have information about masking the
execute perms for both groups. The ACL would also fail aclcheck.
And while get_posix_access now returns the "is standard acl" flag,
it hasn't been utilized by set_created_file_access. Rather,
set_created_file_access has simply continued to check for
nentries > MIN_ACL_ENTRIES, which led to all kinds of weird group
and CLASS_OBJ perms. The new code now always manipulates CLASS_OBJ
perms if a CLASS_OBJ is present, and it always manipulates group perms
if the ACL has been marked as "standard" ACL.
Another problem (not related to commit 97d0449) is the order
get_posix_access adds missing perms. CLASS_OBJ perms are computed
*before* missing GROUP_OBJ perms have been added. Thus the CLASS_OBJ
perms could be too tight and led to additional, buggy DENY ACEs.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/sec_acl.cc')
-rw-r--r-- | winsup/cygwin/sec_acl.cc | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc index 64d183c48..4a47d22b1 100644 --- a/winsup/cygwin/sec_acl.cc +++ b/winsup/cygwin/sec_acl.cc @@ -809,7 +809,6 @@ get_posix_access (PSECURITY_DESCRIPTOR psd, aclsid[pos] = well_known_null_sid; } has_class_perm = true; - standard_ACEs_only = false; class_perm = lacl[pos].a_perm; } if (ace->Header.AceFlags & SUB_CONTAINERS_AND_OBJECTS_INHERIT) @@ -1013,6 +1012,21 @@ get_posix_access (PSECURITY_DESCRIPTOR psd, } } } + /* If this is a just created file, and this is an ACL with only standard + entries, or if standard POSIX permissions are missing (probably no + inherited ACEs so created from a default DACL), assign the permissions + specified by the file creation mask. The values get masked by the + actually requested permissions by the caller per POSIX 1003.1e draft 17. */ + if (just_created) + { + mode_t perms = (S_IRWXU | S_IRWXG | S_IRWXO) & ~cygheap->umask; + if (standard_ACEs_only || !saw_user_obj) + lacl[0].a_perm = (perms >> 6) & S_IRWXO; + if (standard_ACEs_only || !saw_group_obj) + lacl[1].a_perm = (perms >> 3) & S_IRWXO; + if (standard_ACEs_only || !saw_other_obj) + lacl[2].a_perm = perms & S_IRWXO; + } /* If this is an old-style or non-Cygwin ACL, and secondary user and group entries exist in the ACL, fake a matching CLASS_OBJ entry. The CLASS_OBJ permissions are the or'ed permissions of the primary group permissions @@ -1041,21 +1055,6 @@ get_posix_access (PSECURITY_DESCRIPTOR psd, lacl[pos].a_perm = lacl[1].a_perm; /* == group perms */ aclsid[pos] = well_known_null_sid; } - /* If this is a just created file, and this is an ACL with only standard - entries, or if standard POSIX permissions are missing (probably no - inherited ACEs so created from a default DACL), assign the permissions - specified by the file creation mask. The values get masked by the - actually requested permissions by the caller per POSIX 1003.1e draft 17. */ - if (just_created) - { - mode_t perms = (S_IRWXU | S_IRWXG | S_IRWXO) & ~cygheap->umask; - if (standard_ACEs_only || !saw_user_obj) - lacl[0].a_perm = (perms >> 6) & S_IRWXO; - if (standard_ACEs_only || !saw_group_obj) - lacl[1].a_perm = (perms >> 3) & S_IRWXO; - if (standard_ACEs_only || !saw_other_obj) - lacl[2].a_perm = perms & S_IRWXO; - } /* Ensure that the default acl contains at least DEF_(USER|GROUP|OTHER)_OBJ entries. */ if (types_def && (pos = searchace (lacl, MAX_ACL_ENTRIES, 0)) >= 0) |