Bug 816708 - id and groups commands sometimes lie
Summary: id and groups commands sometimes lie
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: coreutils
Version: 6.4
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: ---
Assignee: Ondrej Vasik
QA Contact: Tomas Dolezal
: 1003963 (view as bug list)
Depends On:
Blocks: 1016163 1115430
TreeView+ depends on / blocked
Reported: 2012-04-26 18:40 UTC by Marc Mengel
Modified: 2019-05-20 11:02 UTC (History)
5 users (show)

Fixed In Version: coreutils-8.4-22.el6
Doc Type: Bug Fix
Doc Text:
Cause: Commands id and groups, when invoked with no user name argument, print the default group ID listed in the password database. Consequence: Sometimes, that ID would be neither real nor effective - especially when it changes. Fix: Only effective and/or real ids are printed for the case when no user is specified. Result: Commands id -G and groups now show correct information about the groups.
Clone Of:
: 1016163 (view as bug list)
Last Closed: 2013-11-21 20:55:04 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 473493 0 None None None Never
Red Hat Product Errata RHSA-2013:1652 0 normal SHIPPED_LIVE Low: coreutils security, bug fix, and enhancement update 2013-11-20 21:53:21 UTC

Description Marc Mengel 2012-04-26 18:40:19 UTC
Description of problem:

The "id" and "groups" commands report that you have whatever group
is listed as your primary group in /etc/passwd, regardless whether
you currently have that group id.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:

1. in one window: su - mysql
2. in another window: su -
3. in the mysql window run "id"
4. in the root window, edit /etc/passwd and change mysql's primary group to 123456
5. in the mysql window, run "id" again 
6. put mysql's group id back in /etc/passwd.

Actual results:

in mysql window, you get:
# su - mysql
-bash-4.1$ id
uid=27(mysql) gid=27(mysql) groups=27(mysql) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
-bash-4.1$ id
uid=27(mysql) gid=27(mysql) groups=123456,27(mysql) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
note how we appear to have gained group 123456.

Expected results:

id should print the same result, as our groups have not changed:
# su - mysql
-bash-4.1$ id
uid=27(mysql) gid=27(mysql) groups=27(mysql) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
-bash-4.1$ id
uid=27(mysql) gid=27(mysql) groups=27(mysql) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

Additional info:

Appears to have been reported, but not acted on, before:

Comment 2 Ondrej Vasik 2012-04-27 10:12:45 UTC
IMHO this is not a bug in coreutils(and therefore probably not reacted by upstream). If you want to pursue that further, than it probably should be changed in kernel/glibc. Utilities id/groups just use getgroups()/getgrouplist() for getting the group lists and can't do much with the result. I'll try to reassign it to glibc - although probably not a bug there as well.

In addition - coreutils info documentation for id command states:
"Primary and supplementary groups for a process are normally inherited
from its parent and are usually unchanged since login.  This means that
if you change the group database after logging in, `id' will not
reflect your changes within your existing login session.  Running `id'
with a user argument causes the user and group database to be consulted
afresh, and so will give a different result."

Therefore - when I edit /etc/passwd similarly to your report - change primary group to 504(which you may consider strange as well):
$ id
uid=502(tcsh) gid=503(tcsh) groups=504(tmpgroup),503(tcsh) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
$ id tcsh
uid=502(tcsh) gid=504(tmpgroup) groups=504(tmpgroup)

Comment 3 Jim Meyering 2012-04-27 11:23:06 UTC
Hi Ondrej

I think this will be fixed in coreutils after all, since
it seems more useful (and matches my recollection of the intent)
to print only real and effective IDs when no user name is specified.

Here's the patch I'm considering:


so I've switched the component back to coreutils.

Comment 4 Ondrej Vasik 2012-04-27 11:51:02 UTC
Hi Jim,
thanks for the comment&patch, I haven't realized that in my check... ok, it does make sense...

Comment 6 RHEL Program Management 2012-09-07 05:08:51 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.

Comment 11 Ondrej Vasik 2013-09-04 07:00:07 UTC
*** Bug 1003963 has been marked as a duplicate of this bug. ***

Comment 15 errata-xmlrpc 2013-11-21 20:55:04 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.