Date: Tue, 2 Jan 2007 14:53:36 -0600 From: Vulpes Velox <v.velox@vvelox.net> To: Peter Jeremy <peterjeremy@optushome.com.au> Cc: freebsd-hackers@freebsd.org Subject: Re: getgroups and getgrouplist functions Message-ID: <20070102145336.462e5700@vixen42> In-Reply-To: <20070102094637.GA836@turion.vk2pj.dyndns.org> References: <20070101233525.0b10a1e2@vixen42> <20070102094637.GA836@turion.vk2pj.dyndns.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 2 Jan 2007 20:46:38 +1100 Peter Jeremy <peterjeremy@optushome.com.au> wrote: > On Mon, 2007-Jan-01 23:35:25 -0600, Vulpes Velox wrote: > >I am reading it as int *ngroups is not set to the number of groups > >in the list if the number of groups is larger than the number > >specified. > > I read getgrouplist(3) as stating that it will always return the > actual number of groups via ngroups. The code in RELENG_6 actually > returns the number of groups that are returned via groups - which is > never be greater than was passed in. I believe that the manpage > does not match the implementation but I am not certain which is > correct. I am not reading at always in this case. The man pages for other systems do specify always, but a bit iffy here. From testing it appears it is not set and ngroups is left alone if it is to small. I found it is set to the number if that number is less than the initial ngroups value. So far I know NetBSD, glibc, and what ever Mac uses makes the change. I am lost on if this is a bug or if FreeBSD is not following some standard in regards to this. > >convinced this is a load of bull. And the proper way to get the > >number of groups some one is in is to call getgroups(0). > > At least in RELENG_6, getgroups(2) states that passing the first > argument as 0 will return the number of groups: getgroups(0, NULL); > This matches the code in the kernel. Yeah. The patch I made for DBus last uses this upon failing the first time.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070102145336.462e5700>