public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: getgrent: fix local SAM enumeration on domain member machines
@ 2024-02-20 22:56 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2024-02-20 22:56 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=15e82eef3a40b8a74a5ee8aa85dc7214f0237557

commit 15e82eef3a40b8a74a5ee8aa85dc7214f0237557
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Tue Feb 20 23:51:33 2024 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Tue Feb 20 23:51:33 2024 +0100

    Cygwin: getgrent: fix local SAM enumeration on domain member machines
    
    Don't skip output of local SAM groups on domain member machines.
    They can have valid, user-defined groups in their SAM.  Just
    skip builtin groups if we're enumerating AD as well.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/grp.cc    | 12 +++++++++---
 winsup/cygwin/passwd.cc |  2 --
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index b06ad379128a..77cf6a72c69f 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -424,9 +424,15 @@ gr_ent::enumerate_local ()
 	  DWORD dlen = DNLEN + 1;
 	  SID_NAME_USE acc_type;
 
-	  LookupAccountNameW (NULL,
-			      ((PLOCALGROUP_INFO_0) buf)[cnt++].lgrpi0_name,
-			      sid, &slen, dom, &dlen, &acc_type);
+	  if (!LookupAccountNameW (NULL,
+				 ((PLOCALGROUP_INFO_0) buf)[cnt++].lgrpi0_name,
+				 sid, &slen, dom, &dlen, &acc_type))
+	    continue;
+	  if (sid_id_auth (sid) == 5 /* SECURITY_NT_AUTHORITY */
+	      && sid_sub_auth (sid, 0) == SECURITY_BUILTIN_DOMAIN_RID
+	      && cygheap->dom.member_machine ()
+	      && nss_db_enum_primary ())
+	    continue;
 	  fetch_user_arg_t arg;
 	  arg.type = SID_arg;
 	  arg.sid = &sid;
diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc
index d1708953d353..0be8aa6b8b0e 100644
--- a/winsup/cygwin/passwd.cc
+++ b/winsup/cygwin/passwd.cc
@@ -385,8 +385,6 @@ pg_ent::getent (void)
     case from_local:
       if (from_db
 	  && nss_db_enum_local ()
-	  && (!cygheap->dom.member_machine ()
-	      || !nss_db_enum_primary ())
 	  && (entry = enumerate_local ()))
 	return entry;
       state = from_sam;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-20 22:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-20 22:56 [newlib-cygwin/main] Cygwin: getgrent: fix local SAM enumeration on domain member machines 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).