diff options
author | Brooks Davis <brooks@FreeBSD.org> | 2009-06-19 15:58:24 +0000 |
---|---|---|
committer | Brooks Davis <brooks@FreeBSD.org> | 2009-06-19 15:58:24 +0000 |
commit | 54404cfb13d40e474f72d3c75de1f4db3417df64 (patch) | |
tree | b7d4401847de9bebf98c6fe35d5b61bfd749c7dc /lib/libc/gen/initgroups.3 | |
parent | 68cc62cec1384a3e08391dc734b0ff16f6eda869 (diff) | |
download | src-54404cfb13d40e474f72d3c75de1f4db3417df64.tar.gz src-54404cfb13d40e474f72d3c75de1f4db3417df64.zip |
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
Notes
Notes:
svn path=/head/; revision=194494
Diffstat (limited to 'lib/libc/gen/initgroups.3')
-rw-r--r-- | lib/libc/gen/initgroups.3 | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/libc/gen/initgroups.3 b/lib/libc/gen/initgroups.3 index 2fe2dd984e16..3ed3ca76aae4 100644 --- a/lib/libc/gen/initgroups.3 +++ b/lib/libc/gen/initgroups.3 @@ -65,6 +65,13 @@ function may fail and set .Va errno for any of the errors specified for the library function .Xr setgroups 2 . +It may also return: +.Bl -tag -width Er +.It Bq Er ENOMEM +The +.Fn initgroups +function was unable to allocate temporary storage. +.El .Sh SEE ALSO .Xr setgroups 2 , .Xr getgrouplist 3 |