Date: Thu, 22 Mar 2001 12:34:12 -0500 (EST) From: rwatson@freebsd.org To: FreeBSD-gnats-submit@freebsd.org Subject: docs/26003: getgroups(2) lists NGROUPS_MAX but not syslimits.h Message-ID: <200103221734.f2MHYCH12034@fledge.watson.org>
index | next in thread | raw e-mail
>Number: 26003
>Category: docs
>Synopsis: getgroups(2) lists NGROUPS_MAX but not syslimits.h
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-doc
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: doc-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Mar 22 09:40:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Robert Watson
>Release: FreeBSD 4.2-STABLE i386
>Organization:
FreeBSD Project
>Environment:
FreeBSD fledge.watson.org 4.2-STABLE FreeBSD 4.2-STABLE #0: Wed Jan 31 17:29:21 EST 2001 root@fledge.watson.org:/usr/obj/data/fbsd-stable/src/sys/FLEDGE i386
FreeBSD sproing.gw.tislabs.com 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Tue Feb 27 15:45:03 EST 2001 rwatson@sproing.gw.tislabs.com:/usr/obj/usr/src/sys/GENERIC i386
>Description:
man getgroups notes that no more than NGROUPS_MAX will be returned by the
function, suggesting that this is an upper bound on the gidset array that can
be used by an application. However, the man page lists only sys/types.h and
unistd.h as required include files, and NGROUPS_MAX is not defined in either
of those. To get NGROUPS_MAX, it is necessary to include sys/syslimits.h.
SYNOPSIS
#include <sys/types.h>
#include <unistd.h>
int
getgroups(int gidsetlen, gid_t *gidset)
...
number of entries that may be placed in gidset. Getgroups() returns the
actual number of groups returned in gidset. No more than NGROUPS_MAX
will ever be returned. If gidsetlen is zero, getgroups() returns the
number of supplementary group IDs associated with the calling process
without modifying the array pointed to by gidset.
>How-To-Repeat:
# cat > test.c
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
int
main(int argc, char *argv[])
{
gid_t gidset[NGROUPS_MAX];
int error;
error = getgroups(NGROUPS_MAX, gidset);
if (error)
perror("getgroups");
return (0);
}
<Ctrl-D>
# gcc -o test test.c
test.c: In function `main':
test.c:7: `NGROUPS_MAX' undeclared (first use in this function)
test.c:7: (Each undeclared identifier is reported only once
test.c:7: for each function it appears in.)
>Fix:
Modify man page to include syslimits.h, replicate value into types.h,
other bogosities of namespace, remove reference to NGROUPS_MAX in the man
page. Note clear which is the worst. What does POSIX say about
getgroups()?
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-doc" in the body of the message
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200103221734.f2MHYCH12034>
