Apparently getgrouplist() can fail on OSX for when passed a non-existent
group name. Other platforms seem to return a group list consisting of
the numeric gid passed to the function.
This makes ga_init() handle this failure case gracefully, where it will
return success but with an empty group list array.
bz3848; ok dtucker@
groups_bygid = xcalloc(ngroups, sizeof(*groups_bygid));
while (getgrouplist(user, base, groups_bygid, &ngroups) == -1) {
+ if (ngroups <= ongroups) {
+ error("getgrouplist(\"%s\", %ld): failed",
+ user, (long)base);
+ free(groups_bygid);
+ groups_bygid = NULL;
+ ngroups = 0;
+ return 0;
+ }
if (retry++ > 0) {
fatal("getgrouplist(\"%s\", %ld): groups list too big "
"(have %ld, need %ld)", user, (long)base,