From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id E18793858D20; Tue, 20 Feb 2024 22:56:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E18793858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1708469784; bh=I+IOBTPGmoJPXgZuznFE1l4jNHLVqsItPhKEsOx9CJI=; h=From:To:Subject:Date:From; b=i+4/jg6DBPYQg6hkD/4vaedPGsjQWTYDOMdtdyZoE4ocf5Dhl1mF3ga1gRkXeO7A7 eP5XUPI+pZTP/30ob254VU/NPo4kPwPwhplyw/rviHrkd4t0pezzYlBZHq6+sMZVlW W66nfrJmt4gMDz3+Dk+Zi4Bu1ykQ8jqM7EeTCP+Y= 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: getgrent: fix local SAM enumeration on domain member machines X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 5cc69969878d1a251021a4f62907aeea05cad01f X-Git-Newrev: 15e82eef3a40b8a74a5ee8aa85dc7214f0237557 Message-Id: <20240220225624.E18793858D20@sourceware.org> Date: Tue, 20 Feb 2024 22:56:24 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D15e82eef3a4= 0b8a74a5ee8aa85dc7214f0237557 commit 15e82eef3a40b8a74a5ee8aa85dc7214f0237557 Author: Corinna Vinschen AuthorDate: Tue Feb 20 23:51:33 2024 +0100 Commit: Corinna Vinschen CommitDate: Tue Feb 20 23:51:33 2024 +0100 Cygwin: getgrent: fix local SAM enumeration on domain member machines =20 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. =20 Signed-off-by: Corinna Vinschen 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 =3D DNLEN + 1; SID_NAME_USE acc_type; =20 - 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) =3D=3D 5 /* SECURITY_NT_AUTHORITY */ + && sid_sub_auth (sid, 0) =3D=3D SECURITY_BUILTIN_DOMAIN_RID + && cygheap->dom.member_machine () + && nss_db_enum_primary ()) + continue; fetch_user_arg_t arg; arg.type =3D SID_arg; arg.sid =3D &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 =3D enumerate_local ())) return entry; state =3D from_sam;