diff options
Diffstat (limited to 'which.c')
| -rw-r--r-- | which.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -8,10 +8,12 @@ and to strip out unneeded functionality. */ -#include "rc.h" #include <errno.h> #include <sys/stat.h> +#include "rc.h" +#include "getgroups.h" + #define X_USR 0100 #define X_GRP 0010 #define X_OTH 0001 @@ -83,7 +85,15 @@ extern char *which(char *name, bool verbose) { uid = geteuid(); gid = getegid(); #if HAVE_GETGROUPS +#if HAVE_POSIX_GETGROUPS ngroups = getgroups(0, (GETGROUPS_T *)0); + if (ngroups < 0) { + uerror("getgroups"); + rc_exit(1); + } +#else + ngroups = NGROUPS; +#endif gidset = ealloc(ngroups * sizeof(GETGROUPS_T)); getgroups(ngroups, gidset); #endif |