summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-12-04 08:06:55 -0700
committerEric Blake <ebb9@byu.net>2009-12-04 19:18:06 -0700
commit9b4b38f56e854f8f1343fed9dbc225ffbb1d77d4 (patch)
tree019ad2a21b62a3ec30eec76b5891c8a749abc377 /src
parent5224fbd6f904633b72f4bfa9d64e903744b0beae (diff)
downloadcoreutils-9b4b38f56e854f8f1343fed9dbc225ffbb1d77d4.tar.xz
id: handle systems without getgroups support
If getgroups failed with ENOSYS, mgetgroups would unnecessarily fail, and that provoked id into freeing an uninitialized pointer. Meanwhile, we were not using xalloc_die properly. Both issues are better solved in gnulib, by introducing xgetgroups; this patch uses the new interface. Regression introduced by commit 6a31fd8d7. * gnulib: Update, for mgetgroups improvments. * src/id.c (print_full_info): Adjust caller to die on allocation failure, and no longer worry about ENOSYS. * src/group-list.c (print_group_list): Likewise. * src/setuidgid.c (main): Likewise. * NEWS: Mention the fix. * THANKS: Update. Reported by Scott Harrison.
Diffstat (limited to 'src')
-rw-r--r--src/group-list.c4
-rw-r--r--src/id.c4
-rw-r--r--src/setuidgid.c2
3 files changed, 5 insertions, 5 deletions
diff --git a/src/group-list.c b/src/group-list.c
index 1fadd0c57..a4b1f6dc6 100644
--- a/src/group-list.c
+++ b/src/group-list.c
@@ -58,9 +58,9 @@ print_group_list (const char *username,
gid_t *groups;
int i;
- int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
+ int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
&groups);
- if (n_groups < 0 && errno != ENOSYS)
+ if (n_groups < 0)
{
if (username)
{
diff --git a/src/id.c b/src/id.c
index 9a00f5ce4..96d8e965e 100644
--- a/src/id.c
+++ b/src/id.c
@@ -296,9 +296,9 @@ print_full_info (const char *username)
gid_t *groups;
int i;
- int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
+ int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
&groups);
- if (n_groups < 0 && errno != ENOSYS)
+ if (n_groups < 0)
{
if (username)
{
diff --git a/src/setuidgid.c b/src/setuidgid.c
index 0adac215c..2710bc9de 100644
--- a/src/setuidgid.c
+++ b/src/setuidgid.c
@@ -179,7 +179,7 @@ main (int argc, char **argv)
#if HAVE_SETGROUPS
if (n_gids == 0)
{
- int n = mgetgroups (pwd->pw_name, pwd->pw_gid, &gids);
+ int n = xgetgroups (pwd->pw_name, pwd->pw_gid, &gids);
if (n <= 0)
error (EXIT_FAILURE, errno, _("failed to get groups for user %s"),
quote (pwd->pw_name));