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

commit d1767752ac940c46314ce1c24634a306cb02feff
Author:     Corinna Vinschen <[email protected]>
AuthorDate: Fri Dec 5 17:11:49 2025 +0100
Commit:     Corinna Vinschen <[email protected]>
CommitDate: Mon Dec 22 12:37:23 2025 +0100

    Cygwin: uinfo: allow to override user account as primary group
    
    Do not only allow to override the (localized) group "None" as primary
    group, but also the user account.  The user account is used as primary
    group in the user token, if the user account is a Microsoft Account or
    an AzureAD account.
    
    Fixes: dc7b67316d01 ("Cygwin: uinfo: prefer token primary group")
    Signed-off-by: Corinna Vinschen <[email protected]>
    (cherry picked from commit 351adcd96f026a4ac4e771764d5dbc512190dbf2)

Diff:
---
 winsup/cygwin/uinfo.cc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index 8e9b9e07de9d..fb4618b8a19e 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -170,13 +170,17 @@ internal_getlogin (cygheap_user &user)
         group of a local user ("None", localized), we have to find the SID
         of that group and try to override the token primary group.  Also
         makes sure we're not on a domain controller, where account_sid ()
-        == primary_sid (). */
+        == primary_sid ().
+        CV 2025-12-05: Microsoft Accounts as well as AzureAD accounts have
+        the primary group SID in their user token set to their own user SID.
+        Allow to override them as well. */
       gsid = cygheap->dom.account_sid ();
       gsid.append (DOMAIN_GROUP_RID_USERS);
       if (!pgrp
          || (pwd->pw_gid != pgrp->gr_gid
              && cygheap->dom.account_sid () != cygheap->dom.primary_sid ()
-             && RtlEqualSid (gsid, user.groups.pgsid)))
+             && (gsid == user.groups.pgsid
+                 || user.sid () == user.groups.pgsid)))
        {
          if (gsid.getfromgr (grp = internal_getgrgid (pwd->pw_gid, &cldap)))
            {

Reply via email to