1 /*********************************************************************** 2 * * 3 * This software is part of the ast package * 4 * Copyright (c) 1985-2011 AT&T Intellectual Property * 5 * and is licensed under the * 6 * Eclipse Public License, Version 1.0 * 7 * by AT&T Intellectual Property * 8 * * 9 * A copy of the License is available at * 10 * http://www.eclipse.org/org/documents/epl-v10.html * 11 * (with md5 checksum b35adb5213ca9657e911e9befb180842) * 12 * * 13 * Information and Software Systems Research * 14 * AT&T Research * 15 * Florham Park NJ * 16 * * 17 * Glenn Fowler <gsf@research.att.com> * 18 * David Korn <dgk@research.att.com> * 19 * Phong Vo <kpv@research.att.com> * 20 * * 21 ***********************************************************************/ 22 #pragma prototyped 23 24 #include <ast.h> 25 26 #if !defined(getgroups) && defined(_lib_getgroups) 27 28 NoN(getgroups) 29 30 #else 31 32 #include <error.h> 33 34 #if defined(getgroups) 35 #undef getgroups 36 #define ast_getgroups _ast_getgroups 37 #define botched 1 38 extern int getgroups(int, int*); 39 #else 40 #define ast_getgroups getgroups 41 #endif 42 43 #if defined(__EXPORT__) 44 #define extern __EXPORT__ 45 #endif 46 47 extern int 48 ast_getgroups(int len, gid_t* set) 49 { 50 #if botched 51 #if NGROUPS_MAX < 1 52 #undef NGROUPS_MAX 53 #define NGROUPS_MAX 1 54 #endif 55 register int i; 56 int big[NGROUPS_MAX]; 57 #else 58 #undef NGROUPS_MAX 59 #define NGROUPS_MAX 1 60 #endif 61 if (!len) return(NGROUPS_MAX); 62 if (len < 0 || !set) 63 { 64 errno = EINVAL; 65 return(-1); 66 } 67 #if botched 68 len = getgroups(len > NGROUPS_MAX ? NGROUPS_MAX : len, big); 69 for (i = 0; i < len; i++) 70 set[i] = big[i]; 71 return(len); 72 #else 73 *set = getgid(); 74 return(1); 75 #endif 76 } 77 78 #endif 79