Subject: bug#7320: 'group' command gives wrong/extra group

From: [email-masked]
Date: Tue, 2 Nov 2010 16:40:21 -0500

Hi,

  It appears that the 'groups' command doesn't get the list of groups
for a currently-running process quite right.  The conditions I tested
were where the UID and EUID of the process were different, and the GID
and EGID were both set to the primary group of the EUID.  The groups
command looked up the real user and added the primary group from
/etc/passwd to the list of groups the user was in, even though the
process had no permissions for this extra group.

So, for example say /etc/passwd has at least these 2 entries:

root:x:0:0:root:/root:/bin/sh
user:x:1000:1000:user:/home/user:/bin/sh

and /etc/group has at least these 3 entries:
root:x:0:
other:x:500:
user:x:1000:

If a process as UID=0, EUID=1000, GID=1000, and EGID=1000 and no
supplemental groups, the correct list of groups should be

user

but the groups command shows

user root

If the passwd file is changed like so:

root:x:0:500:root:/root:/bin/sh

then the output of groups is

user other

---
Tested on Debian Slink

groups (GNU coreutils) 8.5
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie and James Youngman.

-- 
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
<>  Brynnen Owen            (     this space for rent                      )<>
<>  [email-masked]       (                                              )<>
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>