/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* David Korn <[email protected]> *18* Phong Vo <[email protected]> *19* *20***********************************************************************/21#pragma prototyped2223#include <ast.h>2425#if !defined(getgroups) && defined(_lib_getgroups)2627NoN(getgroups)2829#else3031#include <error.h>3233#if defined(getgroups)34#undef getgroups35#define ast_getgroups _ast_getgroups36#define botched 137extern int getgroups(int, int*);38#else39#define ast_getgroups getgroups40#endif4142#if defined(__EXPORT__)43#define extern __EXPORT__44#endif4546extern int47ast_getgroups(int len, gid_t* set)48{49#if botched50#if NGROUPS_MAX < 151#undef NGROUPS_MAX52#define NGROUPS_MAX 153#endif54register int i;55int big[NGROUPS_MAX];56#else57#undef NGROUPS_MAX58#define NGROUPS_MAX 159#endif60if (!len) return(NGROUPS_MAX);61if (len < 0 || !set)62{63errno = EINVAL;64return(-1);65}66#if botched67len = getgroups(len > NGROUPS_MAX ? NGROUPS_MAX : len, big);68for (i = 0; i < len; i++)69set[i] = big[i];70return(len);71#else72*set = getgid();73return(1);74#endif75}7677#endif787980