From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id DC67F3858000; Thu, 9 Feb 2023 21:01:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC67F3858000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675976480; bh=J8bnMWnNN6Kt2njLEvS/3z+C3QL318BLIIuHAHGMaxg=; h=From:To:Subject:Date:From; b=MHMWxs+/GAz+OgIPUYzws5J6o9o85Ke75EUBM+Mv7GmrSaIiUwkdCegHmvGipzloV +JehTeFptFa+8ilxa6MLlGn87MITFgoG3xGu3pYiQeSuJp8NZhcme4pwfZxSMI+Kn7 3bHUQ6/ZXRZUdiB+McbNYL5OWPM/3EOFPt9dob5k= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_4-branch] Cygwin: chmod: don't drop default ACEs from directory ACLs X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/cygwin-3_4-branch X-Git-Oldrev: 56751f7f05dca86be15642628c874ea0b2207fc6 X-Git-Newrev: b66979e1523eea3fbcec9b831442881571b83242 Message-Id: <20230209210120.DC67F3858000@sourceware.org> Date: Thu, 9 Feb 2023 21:01:20 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Db66979e1523= eea3fbcec9b831442881571b83242 commit b66979e1523eea3fbcec9b831442881571b83242 Author: Corinna Vinschen AuthorDate: Thu Feb 9 21:47:15 2023 +0100 Commit: Corinna Vinschen CommitDate: Thu Feb 9 21:59:47 2023 +0100 Cygwin: chmod: don't drop default ACEs from directory ACLs =20 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. =20 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. =20 Fixes: bc444e5aa4ca ("Reapply POSIX ACL changes.") Signed-off-by: Corinna Vinschen 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/d= isk_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 =3D false; int nentries, idx; + mode_t attr =3D pc.isdir () ? S_IFDIR : 0; =20 if (!get_file_sd (get_handle (), pc, sd, false)) { aclp =3D (aclent_t *) tp.c_get (); - if ((nentries =3D get_posix_access (sd, NULL, &uid, &gid, + if ((nentries =3D get_posix_access (sd, &attr, &uid, &gid, aclp, MAX_ACL_ENTRIES, &standard_acl)) >=3D 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 =20 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