diff options
author | Petr Stodůlka <pstodulk@redhat.com> | 2014-06-25 18:26:23 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2014-06-26 12:07:10 +0100 |
commit | 408461c0e7e5ddc6bfd0fddb2c79d35a02238ee0 (patch) | |
tree | 217c189cbf8ef3bc5b0279e78a7e2cdfed4c3afe /src/id.c | |
parent | d71c12f1e4e165c7da59989b49ded2805b7977cc (diff) | |
download | coreutils-408461c0e7e5ddc6bfd0fddb2c79d35a02238ee0.tar.xz |
id: output the effective group for the process
* src/id.c (print_full_info): When no user is specified,
output the effective group for the _process_, rather than
the default group from the system database, which may be different.
* tests/id/setgid.sh: Add a case for `id` as well as `id -G`.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/7320
Reported at http://bugzilla.redhat.com/1016163
Diffstat (limited to 'src/id.c')
-rw-r--r-- | src/id.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -399,19 +399,20 @@ print_full_info (const char *username) gid_t *groups; int i; - int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : -1), - &groups); + gid_t primary_group; + if (username) + primary_group = pwd ? pwd->pw_gid : -1; + else + primary_group = egid; + + int n_groups = xgetgroups (username, primary_group, &groups); if (n_groups < 0) { if (username) - { - error (0, errno, _("failed to get groups for user %s"), - quote (username)); - } + error (0, errno, _("failed to get groups for user %s"), + quote (username)); else - { - error (0, errno, _("failed to get groups for the current process")); - } + error (0, errno, _("failed to get groups for the current process")); ok = false; return; } |