Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
DescriptionRon van der Wees
2013-09-03 15:03:38 UTC
Created attachment 793234[details]
Reproducer source code
Description of problem:
/usr/bin/id -G always reports the primary group as defined in /etc/passwd, even
when gid, egid and supplementary group list has been set to a different group.
Version-Release number of selected component (if applicable):
coreutils-8.4-19.el6.x86_64
How reproducible:
Always
Steps to Reproduce:
1. Create additional group:
# groupadd -g 1010 group1010
2. Add user:
# useradd user1
3. Make user member of additional group
# gpasswd -a user1 group1010
4. Build and install reproducer:
# gcc -Wall -o reproducer reproducer2.c
# install -m4755 reproducer /usr/local/bin/reproducer
5. Run reproducer which sets gid/egid to group1010 and calls exceve(2)
to execute "id -G"
Actual results:
On RHEL-6.4:
# su - user1
$ /usr/local/bin/reproducer
1010 501 <<---- Even when gid and egid have been set to 1010, the primary
gid as configured in /etc/passwd is reported while not
not being effective.
Expected results:
On RHEL-5.9:
# su - user1
$ /usr/local/bin/reproducer
1010 <<---- Only the gid as set by reproducer is shown.
Additional info:
The reproducer calls execve(2) in stead of system(3) to avoid bash dropping
the privileges.
From coreutils-8.4/lib/mgetgroups.c in function mgetgroups():
~~~
ng = (username
? getugroups (max_n_groups, g, username, gid)
: getgroups (max_n_groups - (gid != (gid_t) -1),
g + (gid != (gid_t) -1)));
if (ng < 0)
{
/* Failure is unexpected, but handle it anyway. */
int saved_errno = errno;
free (g);
errno = saved_errno;
return -1;
}
if (!username && gid != (gid_t) -1) <-- primary gid is always added to list
{
*g = gid;
ng++;
}
~~~
Created attachment 793234 [details] Reproducer source code Description of problem: /usr/bin/id -G always reports the primary group as defined in /etc/passwd, even when gid, egid and supplementary group list has been set to a different group. Version-Release number of selected component (if applicable): coreutils-8.4-19.el6.x86_64 How reproducible: Always Steps to Reproduce: 1. Create additional group: # groupadd -g 1010 group1010 2. Add user: # useradd user1 3. Make user member of additional group # gpasswd -a user1 group1010 4. Build and install reproducer: # gcc -Wall -o reproducer reproducer2.c # install -m4755 reproducer /usr/local/bin/reproducer 5. Run reproducer which sets gid/egid to group1010 and calls exceve(2) to execute "id -G" Actual results: On RHEL-6.4: # su - user1 $ /usr/local/bin/reproducer 1010 501 <<---- Even when gid and egid have been set to 1010, the primary gid as configured in /etc/passwd is reported while not not being effective. Expected results: On RHEL-5.9: # su - user1 $ /usr/local/bin/reproducer 1010 <<---- Only the gid as set by reproducer is shown. Additional info: The reproducer calls execve(2) in stead of system(3) to avoid bash dropping the privileges. From coreutils-8.4/lib/mgetgroups.c in function mgetgroups(): ~~~ ng = (username ? getugroups (max_n_groups, g, username, gid) : getgroups (max_n_groups - (gid != (gid_t) -1), g + (gid != (gid_t) -1))); if (ng < 0) { /* Failure is unexpected, but handle it anyway. */ int saved_errno = errno; free (g); errno = saved_errno; return -1; } if (!username && gid != (gid_t) -1) <-- primary gid is always added to list { *g = gid; ng++; } ~~~