Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 01 Apr 2001 19:11:36 -0700
From:      Dima Dorfman <dima@unixfreak.org>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        Robert Watson <rwatson@FreeBSD.org>, freebsd-doc@FreeBSD.org, bde@FreeBSD.org
Subject:   Re: docs/26003: getgroups(2) lists NGROUPS_MAX but not syslimits.h 
Message-ID:  <20010402021136.86E8B3E25@bazooka.unixfreak.org>
In-Reply-To: <Pine.BSF.4.21.0104011858330.14800-100000@besplex.bde.org>; from bde@zeta.org.au on "Sun, 1 Apr 2001 20:32:11 %2B1000 (EST)"

next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans <bde@zeta.org.au> writes:
> In POSIX.1-1996:
> 
> 1) NGROUPS_MAX is defined in <limits.h>.  (<sys/syslimits.h> 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
>    <limits.h> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010402021136.86E8B3E25>