On Thu, 18 Dec 2025 12:23:05 +0100
Corinna Vinschen wrote:
> From: Corinna Vinschen <[email protected]>
> 
> Commit dc7b67316d01 ("Cygwin: uinfo: prefer token primary group")
> broke the code overriding the primary group in two different ways:
> 
> - It changed the way myself->gid was set before checking its value.
> 
>   Prior to dc7b67316d01, myself->gid was always set to the primary group
>   from the passwd entry (pw_gid).  With the patch, it was set to the
>   primary group from the Windows user token (token_gid) in the first
>   place.
> 
>   The following condition checking if pw_gid is different
>   from token_gid did so, by checking token_gid against myself->gid,
>   rather than against pw_gid.  After dc7b67316d01 this was always
>   false and the code block overriding the primary group in Cygwin and
>   the Windows user token with pw_gid was never called anymore.
> 
>   The solution is obvious: Do not check token_gid against myself->gid,
>   but against the desires primary GID value in pw_gid instead.
> 
> - The code block overriding the primary group simply assumed that
>   myself->gid was already set to pw_gid, but, as outlined above,
>   this was not true anymore after dc7b67316d01.
> 
>   This is a subtil error, because it leads to having the wrong primary
>   GID in `id' output, while the primary group SID in the user token was
>   correctly set.  But as soon as you run this under strace or GDB, the
>   problem disappears, because the second process tree under GDB or
>   strace takes over from the already changed user token.
> 
>   The solution is to override myself->gid with pw_gid once more, after
>   successfully changing the primary GID to pw_gid.
> 
> Fixes: dc7b67316d01 ("Cygwin: uinfo: prefer token primary group")
> Signed-off-by: Corinna Vinschen <[email protected]>

Having an Addresses tag might be more helpful for readers of the
commit message.

-- 
Takashi Yano <[email protected]>

Reply via email to