1 /* 2 * Copyright (c) 1983 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #if defined(LIBC_SCCS) && !defined(lint) 9 static char sccsid[] = "@(#)initgroups.c 5.8 (Berkeley) 11/12/91"; 10 #endif /* LIBC_SCCS and not lint */ 11 12 /* 13 * initgroups 14 */ 15 #include <sys/param.h> 16 #include <stdio.h> 17 18 int 19 initgroups(uname, agroup) 20 const char *uname; 21 int agroup; 22 { 23 int groups[NGROUPS], ngroups; 24 25 ngroups = NGROUPS; 26 if (getgrouplist(uname, agroup, groups, &ngroups) < 0) 27 fprintf(stderr, 28 "initgroups: %s is in too many groups, using first %d\n", 29 uname, ngroups); 30 if (setgroups(ngroups, groups) < 0) { 31 perror("setgroups"); 32 return (-1); 33 } 34 return (0); 35 } 36