summaryrefslogtreecommitdiffstats
path: root/lib/libc/sys/setgroups.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/setgroups.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/setgroups.2')
-rw-r--r--lib/libc/sys/setgroups.26
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/libc/sys/setgroups.2 b/lib/libc/sys/setgroups.2
index e56e95f..ef4c34c 100644
--- a/lib/libc/sys/setgroups.2
+++ b/lib/libc/sys/setgroups.2
@@ -53,9 +53,7 @@ The
argument
indicates the number of entries in the array and must be no
more than
-.Dv NGROUPS ,
-as defined in
-.In sys/param.h .
+.Dv {NGROUPS_MAX}+1 .
.Pp
Only the super-user may set a new group list.
.Sh RETURN VALUES
@@ -71,7 +69,7 @@ The caller is not the super-user.
The number specified in the
.Fa ngroups
argument is larger than the
-.Dv NGROUPS
+.Dv {NGROUPS_MAX}+1
limit.
.It Bq Er EFAULT
The address specified for
OpenPOWER on IntegriCloud