Cyrus IMAPd 2.3.10 Released

Hajimu UMEMOTO ume at mahoroba.org
Sat Oct 27 13:35:05 EDT 2007


Hi,

>>>>> On Sat, 27 Oct 2007 14:02:59 +0200
>>>>> Tomas Janousek <tjanouse at redhat.com> said:

tjanouse> On Fri, Oct 26, 2007 at 03:30:30PM -0400, Ken Murchison wrote:
>> Perhaps, it should be:
>>     do {
>> 	groupids = (gid_t *)xrealloc((gid_t *)groupids,
>> 				     ngroups * sizeof(gid_t));
>> 	newstate->ngroups = ngroups; /* copy of ngroups for comparision */
>> 	ret = getgrouplist(identifier, gid, groupids, &ngroups);
>> 	/*
>> 	 * This is tricky. We do this as long as getgrouplist tells us to
>> 	 * realloc _and_ the number of groups changes. It tells us to realloc
>> 	 * also in the case of failure...
>> 	 */
>>     } while (ret == -1 && ngroups == newstate->ngroups);
>>              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> I think you're right on the 'ret == -1' test.  We want to stay in the loop 
> if getgrouplist() fails, AND it returns a different number of groups.  

tjanouse> Yes. It should read "ret == -1 && ngroups != newstate->ngroups". I'm really
tjanouse> confused why I put the "ret != -1" in there.

As far as I read the FreeBSD's getgrouplist() implementation, when it
returns -1, the number of the groups actually filled is set to
ngroups.  It is match with the following description in the manpage:

  RETURN VALUES
     The getgrouplist() function returns -1 if the size of the group list is
     too small to hold all the user's groups.  Here, the group array will be
     filled with as many groups as will fit.

So, I think that "ret == -1 && ngroups != newstate->ngroups" doesn't
work on at least FreeBSD.

Sincerely,

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume at mahoroba.org  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/


More information about the Info-cyrus mailing list