summaryrefslogtreecommitdiffstats
path: root/lib/libc/sys/getgroups.2
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2009-06-19 15:58:24 +0000
committerbrooks <brooks@FreeBSD.org>2009-06-19 15:58:24 +0000
commitda4e70cf9ab3e05f67d77de37a7c6c335a5f7e4b (patch)
treeb7d4401847de9bebf98c6fe35d5b61bfd749c7dc /lib/libc/sys/getgroups.2
parent384550a3864abef16c80a82c2fb12d9726aab2d1 (diff)
downloadFreeBSD-src-da4e70cf9ab3e05f67d77de37a7c6c335a5f7e4b.zip
FreeBSD-src-da4e70cf9ab3e05f67d77de37a7c6c335a5f7e4b.tar.gz
In preparation for raising NGROUPS and NGROUPS_MAX, change base
system callers of getgroups(), getgrouplist(), and setgroups() to allocate buffers dynamically. Specifically, allocate a buffer of size sysconf(_SC_NGROUPS_MAX)+1 (+2 in a few cases to allow for overflow). This (or similar gymnastics) is required for the code to actually follow the POSIX.1-2008 specification where {NGROUPS_MAX} may differ at runtime and where getgroups may return {NGROUPS_MAX}+1 results on systems like FreeBSD which include the primary group. In id(1), don't pointlessly add the primary group to the list of all groups, it is always the first result from getgroups(). In principle the old code was more portable, but this was only done in one of the two places where getgroups() was called to the overall effect was pointless. Document the actual POSIX requirements in the getgroups(2) and setgroups(2) manpages. We do not yet support a dynamic NGROUPS, but we may in the future. MFC after: 2 weeks
Diffstat (limited to 'lib/libc/sys/getgroups.2')
-rw-r--r--lib/libc/sys/getgroups.210
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/libc/sys/getgroups.2 b/lib/libc/sys/getgroups.2
index 5eadfe1..4fd8fee 100644
--- a/lib/libc/sys/getgroups.2
+++ b/lib/libc/sys/getgroups.2
@@ -58,10 +58,7 @@ The
system call
returns the actual number of groups returned in
.Fa gidset .
-No more than
-.Dv NGROUPS_MAX
-will ever
-be returned.
+At least one and as many as {NGROUPS_MAX}+1 values may be returned.
If
.Fa gidsetlen
is zero,
@@ -92,6 +89,11 @@ an invalid address.
.Sh SEE ALSO
.Xr setgroups 2 ,
.Xr initgroups 3
+.Sh STANDARDS
+The
+.Fn getgroups
+system call conforms to
+.St -p1003.1-2008 .
.Sh HISTORY
The
.Fn getgroups
OpenPOWER on IntegriCloud