From a69b0cef71e808bebb9ed9fc0f62428710192be1 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 16 Apr 2015 22:23:46 +0200 Subject: [PATCH] Set GROUP_OBJ and CLASS_OBJ perms to new group perms * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Deliberatly set GROUP_OBJ and CLASS_OBJ perms to new group perms. Add comment to explain why. * security.cc (set_created_file_access): Ditto. Signed-off-by: Corinna Vinschen --- winsup/cygwin/ChangeLog | 7 +++++++ winsup/cygwin/fhandler_disk_file.cc | 7 +++++-- winsup/cygwin/security.cc | 7 +++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index ce198e2df..9ec866f2e 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2015-04-16 Corinna Vinschen + + * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Deliberatly + set GROUP_OBJ and CLASS_OBJ perms to new group perms. Add comment + to explain why. + * security.cc (set_created_file_access): Ditto. + 2015-04-16 Corinna Vinschen * sec_acl.cc (set_posix_access): Replace previous patch. Return diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 2b30801bc..b283934c4 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -904,11 +904,14 @@ fhandler_disk_file::fchmod (mode_t mode) /* Overwrite ACL permissions as required by POSIX 1003.1e draft 17. */ aclp[0].a_perm = (mode >> 6) & S_IRWXO; + /* Deliberate deviation from POSIX 1003.1e here. We're not + writing CLASS_OBJ *or* GROUP_OBJ, but both. Otherwise we're + going to be in constant trouble with user expectations. */ + if ((idx = searchace (aclp, nentries, GROUP_OBJ)) >= 0) + aclp[idx].a_perm = (mode >> 3) & S_IRWXO; if (nentries > MIN_ACL_ENTRIES && (idx = searchace (aclp, nentries, CLASS_OBJ)) >= 0) aclp[idx].a_perm = (mode >> 3) & S_IRWXO; - else - aclp[1].a_perm = (mode >> 3) & S_IRWXO; if ((idx = searchace (aclp, nentries, OTHER_OBJ)) >= 0) aclp[idx].a_perm = mode & S_IRWXO; if (pc.isdir ()) diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index ea8563417..170dc1621 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -469,11 +469,14 @@ set_created_file_access (HANDLE handle, path_conv &pc, mode_t attr) /* Overwrite ACL permissions as required by POSIX 1003.1e draft 17. */ aclp[0].a_perm = ((attr & attr_rd) >> 6) & S_IRWXO; + /* Deliberate deviation from POSIX 1003.1e here. We're not + writing CLASS_OBJ *or* GROUP_OBJ, but both. Otherwise we're + going to be in constant trouble with user expectations. */ + if ((idx = searchace (aclp, nentries, GROUP_OBJ)) >= 0) + aclp[idx].a_perm = ((attr & attr_rd) >> 3) & S_IRWXO; if (nentries > MIN_ACL_ENTRIES && (idx = searchace (aclp, nentries, CLASS_OBJ)) >= 0) aclp[idx].a_perm = ((attr & attr_rd) >> 3) & S_IRWXO; - else - aclp[1].a_perm = ((attr & attr_rd) >> 3) & S_IRWXO; if ((idx = searchace (aclp, nentries, OTHER_OBJ)) >= 0) aclp[idx].a_perm = (attr & attr_rd) & S_IRWXO; /* Construct appropriate inherit attribute for new directories.