public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: ACLs: ignore *_INHERIT flags in file ACLs Date: Wed, 12 Jan 2022 09:11:56 +0000 (GMT) [thread overview] Message-ID: <20220112091156.E71B5393A418@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a2bfe7cae61a8bac162bdb06f57d1dd15df3f4b9 commit a2bfe7cae61a8bac162bdb06f57d1dd15df3f4b9 Author: Corinna Vinschen <corinna@vinschen.de> Date: Tue Jan 11 22:20:47 2022 +0100 Cygwin: ACLs: ignore *_INHERIT flags in file ACLs get_posix_access() creates DEF_*_OBJ aclent_t entries from Windows ACEs with INHERIT flags set, independent of the file type. These flags only make sense on directory objects, but certain Windows functions don't check the file type and allow INHERIT ACE flags even on non-directories. As a fix, make sure to ignore the INHERIT flags on non-directory ACLs and don't propagate the matching DEF_*_OBJ aclent_t entries to callers. Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- winsup/cygwin/release/3.3.4 | 3 +++ winsup/cygwin/sec_acl.cc | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/release/3.3.4 b/winsup/cygwin/release/3.3.4 index 048426942..1982df0cf 100644 --- a/winsup/cygwin/release/3.3.4 +++ b/winsup/cygwin/release/3.3.4 @@ -17,3 +17,6 @@ Bug Fixes - Avoid a crash when NtQueryInformationProcess returns invalid handle data. Addresses: https://cygwin.com/pipermail/cygwin-patches/2021q4/011611.html + +- Ignore INHERIT ACEs when reading the DACL of non-directory files. + Addresses: https://cygwin.com/pipermail/cygwin/2022-January/250363.html diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc index 90969b639..98d2391b1 100644 --- a/winsup/cygwin/sec_acl.cc +++ b/winsup/cygwin/sec_acl.cc @@ -811,7 +811,8 @@ get_posix_access (PSECURITY_DESCRIPTOR psd, class_perm = lacl[pos].a_perm; } } - if (ace->Header.AceFlags & SUB_CONTAINERS_AND_OBJECTS_INHERIT) + if (S_ISDIR (attr) + && (ace->Header.AceFlags & SUB_CONTAINERS_AND_OBJECTS_INHERIT) != 0) { if ((pos = searchace (lacl, MAX_ACL_ENTRIES, DEF_CLASS_OBJ)) >= 0) @@ -952,7 +953,8 @@ get_posix_access (PSECURITY_DESCRIPTOR psd, standard_ACEs_only = false; } } - if ((ace->Header.AceFlags & SUB_CONTAINERS_AND_OBJECTS_INHERIT)) + if (S_ISDIR (attr) + && (ace->Header.AceFlags & SUB_CONTAINERS_AND_OBJECTS_INHERIT) != 0) { if (type == USER_OBJ) { @@ -1197,10 +1199,11 @@ int getacl (HANDLE handle, path_conv &pc, int nentries, aclent_t *aclbufp) { security_descriptor sd; + mode_t attr = pc.isdir () ? S_IFDIR : 0; if (get_file_sd (handle, pc, sd, false)) return -1; - int pos = get_posix_access (sd, NULL, NULL, NULL, aclbufp, nentries); + int pos = get_posix_access (sd, &attr, NULL, NULL, aclbufp, nentries); syscall_printf ("%R = getacl(%S)", pos, pc.get_nt_native_path ()); return pos; }
reply other threads:[~2022-01-12 9:11 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220112091156.E71B5393A418@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).