updating the internal copy of the gsid

Pierre A. Humblet Pierre.Humblet@ieee.org
Thu Feb 27 03:25:00 GMT 2003


Have you seen 

A domain user had never run mkpasswd -d nor mkgroup -d
but had a local account with the same username.
When starting, Cygwin looks up /etc/passwd, finds the name
and associates the local uid with the domain sid. 
We could detect the clash, but we are nice and let the program
proceed normally. 

Actually things work out pretty well that way, except that in
internal_getlogin SetTokenInformation(PrimaryGroup) fails
(as it should) but the internal Cygwin copy of the group sid
is updated. Thus files created by Word have a different group
(showing up as ???????) than files created by Cygwin.

To mask the craziness of the situation, the patch below only 
updates the internal Cygwin copy if SetTokenInformation succeeds.
This has no effect in normal cases where the gid is one of the 
token groups.

2003-02-27  Pierre Humblet  <pierre.humblet@ieee.org>
	* uinfo.cc (internal_getlogin): Only update user.groups.pgsid
	if the call to set the primary group succeeds.

Index: uinfo.cc
RCS file: /cvs/src/src/winsup/cygwin/uinfo.cc,v
retrieving revision 1.111
diff -u -p -r1.111 uinfo.cc
--- uinfo.cc    6 Feb 2003 14:01:54 -0000       1.111
+++ uinfo.cc    27 Feb 2003 02:56:06 -0000
@@ -83,10 +83,11 @@ internal_getlogin (cygheap_user &user)
          if (gsid.getfromgr (internal_getgrgid (pw->pw_gid)))
              /* Set primary group to the group in /etc/passwd. */
-             user.groups.pgsid = gsid;
              if (!SetTokenInformation (ptok, TokenPrimaryGroup,
                                        &gsid, sizeof gsid))
                debug_printf ("SetTokenInformation(TokenPrimaryGroup): %E");
+              else
+                user.groups.pgsid = gsid;
            debug_printf ("gsid not found in augmented /etc/group");

More information about the Cygwin-patches mailing list