From b25a9227e193b4bbc5fa6a2920cd924fe5a9bc7d Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 29 Mar 1999 21:27:32 +0000 Subject: initgroups(3) should not spew to stderr; giles@nemeton.com.au Also document the NGROUPS limit. --- lib/libc/gen/initgroups.3 | 10 +++++++++- lib/libc/gen/initgroups.c | 10 +++------- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'lib/libc/gen') diff --git a/lib/libc/gen/initgroups.3 b/lib/libc/gen/initgroups.3 index 8dc8d96e391..f4372d11ff3 100644 --- a/lib/libc/gen/initgroups.3 +++ b/lib/libc/gen/initgroups.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: initgroups.3,v 1.3 1996/08/19 08:24:22 tholo Exp $ +.\" $OpenBSD: initgroups.3,v 1.4 1999/03/29 21:27:30 millert Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -57,6 +57,14 @@ The is automatically included in the group list. Typically this value is given as the group number from the password file. +.Pp +If the groups database lists more than +.Ev NGROUPS +groups for +.Fa name +(including one for +.Fa basegid ) , +the later groups are ignored. .Sh RETURN VALUES The .Fn initgroups diff --git a/lib/libc/gen/initgroups.c b/lib/libc/gen/initgroups.c index 179781e8726..8ded71188c5 100644 --- a/lib/libc/gen/initgroups.c +++ b/lib/libc/gen/initgroups.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: initgroups.c,v 1.4 1997/08/24 21:25:46 millert Exp $"; +static char rcsid[] = "$OpenBSD: initgroups.c,v 1.5 1999/03/29 21:27:31 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -50,12 +50,8 @@ initgroups(uname, agroup) int ngroups; ngroups = NGROUPS; - if (getgrouplist(uname, agroup, groups, &ngroups) < 0) - _warnx("%s is in too many groups, using first %d", - uname, ngroups); - if (setgroups(ngroups, groups) < 0) { - _warn("setgroups"); + (void) getgrouplist(uname, agroup, groups, &ngroups); + if (setgroups(ngroups, groups) < 0) return (-1); - } return (0); } -- cgit v1.2.3