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.
This commit is contained in:
Eric Blake committed 2009-12-04 19:18:06 -07:00
1 parent 5224fbd6f9
commit 9b4b38f56e
6 files changed
+10 -6

No files matched your search

+3
View File
@@ -4,6 +4,9 @@ GNU coreutils NEWS -*- outline -*-
** Bug fixes
id no longer crashes on systems without supplementary group support.
[bug introduced in coreutils-8.1]
rm once again handles zero-length arguments properly.
The rewrite to make rm use fts introduced a regression whereby
a command like "rm a '' b" would fail to remove "a" and "b", due to
+1
View File
@@ -529,6 +529,7 @@ Samuli Karkkainen Samuli.Karkkainen@hut.fi
Sander van Malssen svm@kozmix.ow.nl
Santiago Vila Doncel sanvila@unex.es
Savochkin Andrey Vladimirovich saw@msu.ru
Scott Harrison scott.gnu.2009@scottrix.co.uk
Scott Lurndal slurn@griffin.engr.sgi.com
Sébastien Maret smaret@umich.edu
Sergei Steshenko sergstesh@yahoo.com
+1 -1
Submodule gnulib updated: cdfe647f8d...3e035a5d68.
+2 -2
View File
@@ -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)
{
+2 -2
View File
@@ -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)
{
+1 -1
View File
@@ -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));