diff options
author | Jim Meyering <meyering@redhat.com> | 2008-01-23 14:12:04 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2008-01-26 10:04:17 +0100 |
commit | d81716addb44a89c69c1bcb7643f4792e77881ff (patch) | |
tree | dbe67621a0ac65764a1649483ca901051e274524 /src | |
parent | 3b9b0c5c161e4df0d0b64128241c2d924f70858b (diff) | |
download | coreutils-d81716addb44a89c69c1bcb7643f4792e77881ff.tar.xz |
Avoid misinterpreting mgetgroups failure in running root-only tests.
* src/setuidgid.c (main): Don't misinterpret as size_t an error
return from mgetgroups. Reported by Theodoros V. Kalamatianos.
Diffstat (limited to 'src')
-rw-r--r-- | src/setuidgid.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/setuidgid.c b/src/setuidgid.c index 0f551f9cf..83369fdef 100644 --- a/src/setuidgid.c +++ b/src/setuidgid.c @@ -1,5 +1,5 @@ /* setuidgid - run a command with the UID and GID of a specified user - Copyright (C) 2003-2007 Free Software Foundation, Inc. + Copyright (C) 2003-2008 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -181,10 +181,11 @@ main (int argc, char **argv) #if HAVE_SETGROUPS if (n_gids == 0) { - n_gids = mgetgroups (pwd->pw_name, pwd->pw_gid, &gids); - if (n_gids <= 0) + int n = mgetgroups (pwd->pw_name, pwd->pw_gid, &gids); + if (n <= 0) error (1, errno, _("failed to get groups for user %s"), quote (pwd->pw_name)); + n_gids = n; } if (setgroups (n_gids, gids)) |