From owner-freebsd-doc Sun Apr 1 19:11:40 2001 Delivered-To: freebsd-doc@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 20A5837B71B; Sun, 1 Apr 2001 19:11:37 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from spike.unixfreak.org (spike [63.198.170.139]) by bazooka.unixfreak.org (Postfix) with ESMTP id 86E8B3E25; Sun, 1 Apr 2001 19:11:36 -0700 (PDT) To: Bruce Evans Cc: Robert Watson , freebsd-doc@FreeBSD.org, bde@FreeBSD.org Subject: Re: docs/26003: getgroups(2) lists NGROUPS_MAX but not syslimits.h In-Reply-To: ; from bde@zeta.org.au on "Sun, 1 Apr 2001 20:32:11 +1000 (EST)" Date: Sun, 01 Apr 2001 19:11:36 -0700 From: Dima Dorfman Message-Id: <20010402021136.86E8B3E25@bazooka.unixfreak.org> Sender: owner-freebsd-doc@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Bruce Evans writes: > In POSIX.1-1996: > > 1) NGROUPS_MAX is defined in . ( is BSD > implementation detail, so it shouldn't be documented.) > > 2) NGROUPS_MAX is a "Run-Time Increasable Value". This means that > applications may find that the actual maximum number of groups is > larger than their compile time value of NGROUPS_MAX. The run time > maximum is given by sysconf(_SC_NGROUPS_MAX). > > 3) Unlike some other POSIX limits, NGROUPS_MAX must be defined at > compile time, although its value is almost useless if its run time > value is larger. A footnote says that future revisions of POSIX.1 > are expected to permit omitting the definition of NGROUPS_MAX from > to indicate that its value is variable. Based on this, attached is a proposed patch to getgroups.2. Thanks, Dima Dorfman dima@unixfreak.org Index: getgroups.2 =================================================================== RCS file: /st/src/FreeBSD/src/lib/libc/sys/getgroups.2,v retrieving revision 1.7 diff -u -r1.7 getgroups.2 --- getgroups.2 2000/04/21 09:41:40 1.7 +++ getgroups.2 2001/04/02 02:09:05 @@ -57,10 +57,6 @@ .Fn Getgroups returns the actual number of groups returned in .Fa gidset . -No more than -.Dv NGROUPS_MAX -will ever -be returned. If .Fa gidsetlen is zero, @@ -68,6 +64,19 @@ returns the number of supplementary group IDs associated with the calling process without modifying the array pointed to by .Fa gidset . +.Sh NOTES +.St -p1003.1-96 +defines an +.Dv NGROUPS_MAX +constant in +.Aq Pa limits.h ; +however, this value is +.Qq Run-Time Increasable , +and as such is effectively useless if the run-time value happens to be +larger. +Thus, dynamic allocation of +.Fa gidset +must always be used. .Sh RETURN VALUES A successful call returns the number of groups in the group set. A value of -1 indicates that an error occurred, and the error To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-doc" in the body of the message