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>
This commit is contained in:
Corinna Vinschen 2024-02-20 23:51:33 +01:00
parent 5cc6996987
commit 15e82eef3a
2 changed files with 9 additions and 5 deletions

View File

@ -424,9 +424,15 @@ gr_ent::enumerate_local ()
DWORD dlen = DNLEN + 1; DWORD dlen = DNLEN + 1;
SID_NAME_USE acc_type; SID_NAME_USE acc_type;
LookupAccountNameW (NULL, if (!LookupAccountNameW (NULL,
((PLOCALGROUP_INFO_0) buf)[cnt++].lgrpi0_name, ((PLOCALGROUP_INFO_0) buf)[cnt++].lgrpi0_name,
sid, &slen, dom, &dlen, &acc_type); 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; fetch_user_arg_t arg;
arg.type = SID_arg; arg.type = SID_arg;
arg.sid = &sid; arg.sid = &sid;

View File

@ -385,8 +385,6 @@ pg_ent::getent (void)
case from_local: case from_local:
if (from_db if (from_db
&& nss_db_enum_local () && nss_db_enum_local ()
&& (!cygheap->dom.member_machine ()
|| !nss_db_enum_primary ())
&& (entry = enumerate_local ())) && (entry = enumerate_local ()))
return entry; return entry;
state = from_sam; state = from_sam;