summaryrefslogtreecommitdiff
path: root/which.c
diff options
context:
space:
mode:
authortgoodwin <tgoodwin>1998-07-27 13:26:37 +0000
committerToby Goodwin <toby@paccrat.org>2015-05-16 21:23:11 +0100
commitd3102fa7de519677c917beb108a71b81ef9a8abc (patch)
tree2b30aa4eddaf1f9913fe7e2d1f480c67605465c8 /which.c
parent8a11028b592d1c7a5b408475fdc3028b04ab6ffa (diff)
add RC_FUNC_GETGROUPS configure magic
Diffstat (limited to 'which.c')
-rw-r--r--which.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/which.c b/which.c
index c4bbc29..3d23e3d 100644
--- a/which.c
+++ b/which.c
@@ -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