Bug 816708 - id and groups commands sometimes lie
id and groups commands sometimes lie
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: coreutils (Show other bugs)
6.4
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Ondrej Vasik
Tomas Dolezal
:
: 1003963 (view as bug list)
Depends On:
Blocks: 1016163 1115430
  Show dependency treegraph
 
Reported: 2012-04-26 14:40 EDT by Marc Mengel
Modified: 2014-07-02 06:54 EDT (History)
5 users (show)

See Also:
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.
Story Points: ---
Clone Of:
: 1016163 (view as bug list)
Environment:
Last Closed: 2013-11-21 15:55:04 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 473493 None None None Never

  None (edit)
Description Marc Mengel 2012-04-26 14:40:19 EDT
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):

coreutils-8.4-13.el6.i686

How reproducible:

Easily

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:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7320
Comment 2 Ondrej Vasik 2012-04-27 06:12:45 EDT
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 07:23:06 EDT
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:

    http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7320#14

so I've switched the component back to coreutils.
Comment 4 Ondrej Vasik 2012-04-27 07:51:02 EDT
Hi Jim,
thanks for the comment&patch, I haven't realized that in my check... ok, it does make sense...
Comment 6 RHEL Product and Program Management 2012-09-07 01:08:51 EDT
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 03:00:07 EDT
*** Bug 1003963 has been marked as a duplicate of this bug. ***
Comment 15 errata-xmlrpc 2013-11-21 15:55:04 EST
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.

http://rhn.redhat.com/errata/RHSA-2013-1652.html

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