public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: chmod: don't drop default ACEs from directory ACLs
@ 2023-02-09 21:01 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2023-02-09 21:01 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9afd4c055814ddcb51ba9cc0e99250e5ded852cf
commit 9afd4c055814ddcb51ba9cc0e99250e5ded852cf
Author: Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Thu Feb 9 21:47:15 2023 +0100
Commit: Corinna Vinschen <corinna@vinschen.de>
CommitDate: Thu Feb 9 21:58:20 2023 +0100
Cygwin: chmod: don't drop default ACEs from directory ACLs
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>
Diff:
---
winsup/cygwin/fhandler/disk_file.cc | 3 ++-
winsup/cygwin/release/3.4.6 | 3 +++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/fhandler/disk_file.cc b/winsup/cygwin/fhandler/disk_file.cc
index 6eb466e9c6f4..15dc24ffef62 100644
--- a/winsup/cygwin/fhandler/disk_file.cc
+++ b/winsup/cygwin/fhandler/disk_file.cc
@@ -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)
{
diff --git a/winsup/cygwin/release/3.4.6 b/winsup/cygwin/release/3.4.6
index f9288dc79994..ccc168a9587f 100644
--- a/winsup/cygwin/release/3.4.6
+++ b/winsup/cygwin/release/3.4.6
@@ -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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-09 21:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09 21:01 [newlib-cygwin/main] Cygwin: chmod: don't drop default ACEs from directory ACLs Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).