Date: Mon, 28 Jun 2010 02:31:46 +1000 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Garrett Cooper <yanefbsd@gmail.com> Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Pawel Jakub Dawidek <pjd@FreeBSD.org> Subject: Re: svn commit: r209542 - head/lib/libc/sys Message-ID: <20100628012949.I49091@delplex.bde.org> In-Reply-To: <AANLkTinGp8w6hsBGkDTSwdDLKrz43BGBUbH0Hd4Z6ox3@mail.gmail.com> References: <201006262144.o5QLi5tF076622@svn.freebsd.org> <AANLkTinGp8w6hsBGkDTSwdDLKrz43BGBUbH0Hd4Z6ox3@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
--0-920043072-1277656306=:49091
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE
On Sat, 26 Jun 2010, Garrett Cooper wrote:
Please fix your mail program to not mangle the message with \xa0's.
> On Sat, Jun 26, 2010 at 2:44 PM, Pawel Jakub Dawidek <pjd@freebsd.org> wr=
ote:
>> Log:
>> =A0Just like in case of setgroups(2), for getgroups(2) also advice inclu=
ding
>> =A0sys/param.h instead of sys/types.h so we get NGROUPS_MAX and NGROUPS
>> =A0definitions.
This bug should have been fixed in getgroups.2, not duplicated. It was
fixed in getgroups.2 in 1998, but not in setgroups, presumably because
POSIX only specified getgroups back then:
% RCS file: /home/ncvs/src/lib/libc/sys/getgroups.2,v
% Working file: getgroups.2
% head: 1.12
% ----------------------------
% revision 1.3
% date: 1998/01/11 22:01:20; author: alex; state: Exp; lines: +9 -1
% Replace sys/param.h with sys/types.h as per POSIX.
% Document the special case of gidsetlen =3D=3D 0.
%=20
% Partially obtained from: OpenBSD
% ----------------------------
This is a bug because:
- neither NGROUPS_MAX nor NGROUPS is needed to use get/setgroups(). These
functions take an int arg which may be unrelated to the maximum number
of groups
- all uses of NGROUPS_MAX and NGROUPS are bugs, since they are fixed values
so using them breaks binary compatibility
- FreeBSD was fixed relatively recently to never (?) use NGROUPS_MAX or
NGROUPS. The fixes include removing the reference to NGROUPS max
in getgroups.2 and the reference to NGROUPS in setgroups.2. Now
{NGROUPS_MAX}+1 is used consistently. This cannot be found in
<sys/param.h>. (It's documentation seems to be unfindable in any,
man page but that is another bug. POSIX limits should be described
somewhere like intro.2 and intro.2 should not be cross referenced to.)
> Hmmm... looks like our copy of getgroups(2) is not POSIX compliant
> then :/ : http://www.opengroup.org/onlinepubs/000095399/functions/getgrou=
ps.html
It only used to be, after the 1998 fix. POSIX didn't have setgroups() in
2001 either.
> . Why not just use sysconf like the POSIX page suggests (which is
> portable)?
FreeBSD's man page says this too (implicitly via the {} markup). POSIX
has an explicit example using sysconf(). I prefer not to have such
examples in individual man pages. They are difficult to give in enough
detail to work in general. POSIX has very wrong examples for use of
{LINE_MAX}. Its example for {NGROUPS_MAX} for getgroups() is little
better -- it is missing an include of <stdlib.h> to declare malloc(),
and has no error handling. I would prefer a central example that is
missing these bugs but describes the shortcuts of having them.
Bruce
--0-920043072-1277656306=:49091--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100628012949.I49091>
