]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: chmod: don't drop default ACEs from directory ACLs
authorCorinna Vinschen <corinna@vinschen.de>
Thu, 9 Feb 2023 20:47:15 +0000 (21:47 +0100)
committerCorinna Vinschen <corinna@vinschen.de>
Thu, 9 Feb 2023 20:59:47 +0000 (21:59 +0100)
commit bc444e5aa4ca introduced a call to get_posix_access()
with a NULL pointer for the mode_t parameter because the value
is not needed later on... entirely ignoring the fact that the
mode_t bits are checked for the object being a directory.

In turn, the get_posix_access() call never checked for default
ACEs and returned only the standard ACEs.  Thus, every chmod call
on a directory dropped the default ACEs from its permissions, as
well as the default NULL deny-ACE used to store specific bits.
It got also impossible to set the sgid bit on directories.

Fixes: bc444e5aa4ca ("Reapply POSIX ACL changes.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/fhandler/disk_file.cc
winsup/cygwin/release/3.4.6

index 6eb466e9c6f4373c3fd92f866d674a4c4d82ee8d..15dc24ffef6245c88a7e4464cb2f76ff696cd8f3 100644 (file)
@@ -764,11 +764,12 @@ fhandler_disk_file::fchmod (mode_t mode)
       aclent_t *aclp;
       bool standard_acl = false;
       int nentries, idx;
+      mode_t attr = pc.isdir () ? S_IFDIR : 0;
 
       if (!get_file_sd (get_handle (), pc, sd, false))
        {
          aclp = (aclent_t *) tp.c_get ();
-         if ((nentries = get_posix_access (sd, NULL, &uid, &gid,
+         if ((nentries = get_posix_access (sd, &attr, &uid, &gid,
                                            aclp, MAX_ACL_ENTRIES,
                                            &standard_acl)) >= 0)
            {
index f9288dc7999457036035afc3b6f3968620150bb9..ccc168a9587f71c7af50e7f9ca82b8d7e1056f1f 100644 (file)
@@ -9,3 +9,6 @@ Addresses: https://cygwin.com/pipermail/cygwin/2023-January/252928.html
 
 Create directories with correctly umask-filtered default ACEs.
 Addresses: https://cygwin.com/pipermail/cygwin/2023-February/253037.html
+
+Don't accidentally drop the default ACEs when chmod'ing directories.
+Addresses: https://cygwin.com/pipermail/cygwin/2023-February/253037.html
This page took 0.035393 seconds and 5 git commands to generate.