mgetgroups: add xgetgroups, and avoid ENOSYS failures
authorEric Blake <ebb9@byu.net>
Fri, 4 Dec 2009 15:26:23 +0000 (08:26 -0700)
committerEric Blake <ebb9@byu.net>
Sat, 5 Dec 2009 01:02:53 +0000 (18:02 -0700)
commit3e035a5d686888e5eba0b622dac459b65cdd99d3
treeb1753cc4e7e2f916021c550f0de36a7f5f3e6589
parent3425a9dd708056d5e12483dd917af0c035b8b5bc
mgetgroups: add xgetgroups, and avoid ENOSYS failures

ENOSYS implies that there are no supplemental groups, so we can
treat it the same as a return of 0 from getgroups rather than
exposing failure to the user.  This in turn fixes a crash in
coreutils' id, which freed an uninitialized pointer.

* lib/mgetgroups.h (xgetgroups): New prototype.
* lib/mgetgroups.c (xgetgroups): New wrapper.
(mgetgroups): Handle ENOSYS.
* modules/mgetgroups (Depends-on): Add realloc.
Reported by Scott Harrison <scott.gnu.2009@scottrix.co.uk>.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/mgetgroups.c
lib/mgetgroups.h
modules/mgetgroups