Cygwin: mkdir: use correct default permissions filtered by umask

Older coreutils created directories with mode bits filtered through
umask.  Newer coreutils creates directories with full permissions,
0777 by default.

This new coreutils behaviour uncovered the fact that default ACEs for
newly created directories were not filtered by umask starting with
commit bc444e5aa4.

Fix it by applying umask on the default ACEs.

Fixes: bc444e5aa4 ("Reapply POSIX ACL change.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2023-02-09 21:25:03 +01:00
parent dc70c8dec1
commit 283583c5f2
2 changed files with 8 additions and 3 deletions

View File

@ -6,3 +6,6 @@ Addresses: https://cygwin.com/pipermail/cygwin/2023-January/252916.html
Don't reject valid server and share names when mounting. Don't reject valid server and share names when mounting.
Addresses: https://cygwin.com/pipermail/cygwin/2023-January/252928.html 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

View File

@ -495,23 +495,25 @@ set_created_file_access (HANDLE handle, path_conv &pc, mode_t attr)
S_ISGID bit is set, propagate it. */ S_ISGID bit is set, propagate it. */
if (S_ISDIR (attr)) if (S_ISDIR (attr))
{ {
mode_t def_attr = attr & ~cygheap->umask;
if (searchace (aclp, nentries, DEF_USER_OBJ) < 0) if (searchace (aclp, nentries, DEF_USER_OBJ) < 0)
{ {
aclp[nentries].a_type = DEF_USER_OBJ; aclp[nentries].a_type = DEF_USER_OBJ;
aclp[nentries].a_id = ILLEGAL_UID; aclp[nentries].a_id = ILLEGAL_UID;
aclp[nentries++].a_perm = (attr >> 6) & S_IRWXO; aclp[nentries++].a_perm = (def_attr >> 6) & S_IRWXO;
} }
if (searchace (aclp, nentries, DEF_GROUP_OBJ) < 0) if (searchace (aclp, nentries, DEF_GROUP_OBJ) < 0)
{ {
aclp[nentries].a_type = DEF_GROUP_OBJ; aclp[nentries].a_type = DEF_GROUP_OBJ;
aclp[nentries].a_id = ILLEGAL_GID; aclp[nentries].a_id = ILLEGAL_GID;
aclp[nentries++].a_perm = (attr >> 3) & S_IRWXO; aclp[nentries++].a_perm = (def_attr >> 3) & S_IRWXO;
} }
if (searchace (aclp, nentries, DEF_OTHER_OBJ) < 0) if (searchace (aclp, nentries, DEF_OTHER_OBJ) < 0)
{ {
aclp[nentries].a_type = DEF_OTHER_OBJ; aclp[nentries].a_type = DEF_OTHER_OBJ;
aclp[nentries].a_id = ILLEGAL_UID; aclp[nentries].a_id = ILLEGAL_UID;
aclp[nentries++].a_perm = attr & S_IRWXO; aclp[nentries++].a_perm = def_attr & S_IRWXO;
} }
if (attr_rd & S_ISGID) if (attr_rd & S_ISGID)
attr |= S_ISGID; attr |= S_ISGID;