getgroups(2) doc bug
Scott Hankerson
scottha at azure.UUCP
Fri Mar 23 07:26:05 AEST 1984
The man page for getgroups(2) in 4.2BSD has approached
maximum inaccuracy for a short document. The documentation
claims that the syntax is:
getgroups(ngroups, gidset)
int *ngroups, *gidset;
where \ngroups/ initially points to an integer that informs
the kernel how many integers it may place in \gidset/. After
the call \ngroups/ will point to an integer that tells the
user how many group numbers the kernel actually returned.
The truth is that \ngroups/ must be declared as an integer
and not a pointer! Getgroups then RETURNS the number of
groups numbers the kernel placed into gidset. It doesn't
return 0 on sucess (as the man page claims).
Also, this man page claims that the maximum number of groups
that the kernel can return will be NGRPS which is supposed
to be defined in sys/param.h. It's not NGRPS but NGROUPS.
The easiest way, then, to use getgroups is like this:
int gidset[NGROUPS], n;
n = getgroups(NGROUPS, gidset);
After you change your on-line man page, you may want to
change the lint library.
Scott Hankerson
teklds!tekmdp!scottha
P.S. I noticed that this group list did not replace the old
real and effective group ids but are an addition to the
old group ids. Could someone tell me what relationship
u_gid and u_rgid have with u_grps[] (the group set)?
I noticed (or at least think I noticed) that the access(2)
sys call only uses u_rgid and ignores all of the other
groups that a user is in. Is there a document I missed
somewhere?
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list