Tomas Janousek wrote: > Hi, > > On Sun, Oct 28, 2007 at 03:52:24PM +0900, Hajimu UMEMOTO wrote: >> It seems to me from the source of getgrouplist() that it sets "the >> actual number of groups found" to ngroups only when it returns 0. >> When it returns -1, "the number of groups actually filled" is set to >> ngroups. I think that it is what the RETURN VALUES section in >> FreeBSD's manpage says. > > Ok, I looked at the source and now I see it. And I think the source is really > wrong (e.g. the write to groups without checking ngroups is non-zero -- this > was fixed in glibc a looong time ago). > >> So, I think that "ret == -1 && ngroups != newstate->ngroups" would be >> always FALSE at least on FreeBSD. > > Yeah. To make it work on BSD, we should either preallocate big enough an array > and don't care, or realloc to two-times the size whenever ngroups == > newstate->ngroups (and to given size when ngroups > newstate->ngroups, to make > it faster on glibc). > > Thanks for catching this :) I don't have easy access to a BSD platform. Would somebody be willing to write and test such a patch? -- Kenneth Murchison Systems Programmer Project Cyrus Developer/Maintainer Carnegie Mellon University ---- Cyrus Home Page: http://cyrusimap.web.cmu.edu/ Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html