From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 2 20:52:33 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9116E16A416 for ; Tue, 2 Jan 2007 20:52:33 +0000 (UTC) (envelope-from SRS0=5nRf5r=GL=vvelox.net=v.velox@yourhostingaccount.com) Received: from mailout20.yourhostingaccount.com (mailout20.yourhostingaccount.com [65.254.253.166]) by mx1.freebsd.org (Postfix) with ESMTP id 5226913C457 for ; Tue, 2 Jan 2007 20:52:33 +0000 (UTC) (envelope-from SRS0=5nRf5r=GL=vvelox.net=v.velox@yourhostingaccount.com) Received: from scan04.yourhostingaccount.com ([10.1.1.234] helo=scan04.yourhostingaccount.com) by mailout20.yourhostingaccount.com with esmtp (Exim) id 1H1qca-0008Rz-8G for freebsd-hackers@freebsd.org; Tue, 02 Jan 2007 15:52:32 -0500 Received: from authsmtp10.yourhostingaccount.com ([10.1.18.10] ident=exim) by scan04.yourhostingaccount.com with spamscanlookuphost (Exim) id 1H1qca-00089M-2p for freebsd-hackers@freebsd.org; Tue, 02 Jan 2007 15:52:32 -0500 Received: from authsmtp10.yourhostingaccount.com ([10.1.18.10] helo=authsmtp10.yourhostingaccount.com) by scan04.yourhostingaccount.com with esmtp (Exim) id 1H1qcZ-00089G-Ng for freebsd-hackers@freebsd.org; Tue, 02 Jan 2007 15:52:31 -0500 Received: from [69.92.217.33] (helo=vixen42) by authsmtp10.yourhostingaccount.com with esmtpa (Exim) id 1H1qcZ-0006Lx-7O; Tue, 02 Jan 2007 15:52:31 -0500 Date: Tue, 2 Jan 2007 14:53:36 -0600 From: Vulpes Velox To: Peter Jeremy Message-ID: <20070102145336.462e5700@vixen42> In-Reply-To: <20070102094637.GA836@turion.vk2pj.dyndns.org> References: <20070101233525.0b10a1e2@vixen42> <20070102094637.GA836@turion.vk2pj.dyndns.org> X-Mailer: Sylpheed-Claws 2.6.0 (GTK+ 2.10.6; i386-portbld-freebsd6.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-EN-UserInfo: 0d1ca1697cdb7a831d4877828571b7ab:1570f0de6936c69fef9e164fffc541bc X-EN-AuthUser: vvelox2 Sender: Vulpes Velox Cc: freebsd-hackers@freebsd.org Subject: Re: getgroups and getgrouplist functions X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2007 20:52:33 -0000 On Tue, 2 Jan 2007 20:46:38 +1100 Peter Jeremy 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.