From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 5DFD83858C74; Thu, 9 Feb 2023 21:01:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5DFD83858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675976493; bh=Bj2x3fFMkivTYjIHhjo8pTb9iwxGCRAH991UdRo1Lb4=; h=From:To:Subject:Date:From; b=ndW/9rTuwGZgBofizq0ejRv8rkThdMcf0cFYw/xzUUg4vVPzTt5DEL+VlHNmi+FtS gkxw5xiLJOgk1M8Drs2Fzy/canxrImkPvKOOY0ztf2Q98i6KYNpWrICrFYoxDt8leq cxuGOoYQwLADcL4UK4gJ0ZdoB1Pfrjd+MOVR5WKU= 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/main] Cygwin: mkdir: use correct default permissions filtered by umask X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: dc70c8dec19b74f0b8668704a2492b4b04d56b73 X-Git-Newrev: 283583c5f24000dc4a5872725d21c4313d13350f Message-Id: <20230209210133.5DFD83858C74@sourceware.org> Date: Thu, 9 Feb 2023 21:01:33 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D283583c5f24= 000dc4a5872725d21c4313d13350f commit 283583c5f24000dc4a5872725d21c4313d13350f Author: Corinna Vinschen AuthorDate: Thu Feb 9 21:25:03 2023 +0100 Commit: Corinna Vinschen CommitDate: Thu Feb 9 21:58:07 2023 +0100 Cygwin: mkdir: use correct default permissions filtered by umask =20 Older coreutils created directories with mode bits filtered through umask. Newer coreutils creates directories with full permissions, 0777 by default. =20 This new coreutils behaviour uncovered the fact that default ACEs for newly created directories were not filtered by umask starting with commit bc444e5aa4ca. =20 Fix it by applying umask on the default ACEs. =20 Fixes: bc444e5aa4ca ("Reapply POSIX ACL change.") Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/release/3.4.6 | 3 +++ winsup/cygwin/sec/base.cc | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/release/3.4.6 b/winsup/cygwin/release/3.4.6 index c21c44fbf55a..f9288dc79994 100644 --- a/winsup/cygwin/release/3.4.6 +++ b/winsup/cygwin/release/3.4.6 @@ -6,3 +6,6 @@ Addresses: https://cygwin.com/pipermail/cygwin/2023-January= /252916.html =20 Don't reject valid server and share names when mounting. 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 diff --git a/winsup/cygwin/sec/base.cc b/winsup/cygwin/sec/base.cc index dc85ca72acbe..e84bc2aee7f1 100644 --- a/winsup/cygwin/sec/base.cc +++ b/winsup/cygwin/sec/base.cc @@ -495,23 +495,25 @@ set_created_file_access (HANDLE handle, path_conv &pc= , mode_t attr) S_ISGID bit is set, propagate it. */ if (S_ISDIR (attr)) { + mode_t def_attr =3D attr & ~cygheap->umask; + if (searchace (aclp, nentries, DEF_USER_OBJ) < 0) { aclp[nentries].a_type =3D DEF_USER_OBJ; aclp[nentries].a_id =3D ILLEGAL_UID; - aclp[nentries++].a_perm =3D (attr >> 6) & S_IRWXO; + aclp[nentries++].a_perm =3D (def_attr >> 6) & S_IRWXO; } if (searchace (aclp, nentries, DEF_GROUP_OBJ) < 0) { aclp[nentries].a_type =3D DEF_GROUP_OBJ; aclp[nentries].a_id =3D ILLEGAL_GID; - aclp[nentries++].a_perm =3D (attr >> 3) & S_IRWXO; + aclp[nentries++].a_perm =3D (def_attr >> 3) & S_IRWXO; } if (searchace (aclp, nentries, DEF_OTHER_OBJ) < 0) { aclp[nentries].a_type =3D DEF_OTHER_OBJ; aclp[nentries].a_id =3D ILLEGAL_UID; - aclp[nentries++].a_perm =3D attr & S_IRWXO; + aclp[nentries++].a_perm =3D def_attr & S_IRWXO; } if (attr_rd & S_ISGID) attr |=3D S_ISGID;