summaryrefslogtreecommitdiff
path: root/src/misc/getgrouplist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc/getgrouplist.c')
-rw-r--r--src/misc/getgrouplist.c24
1 files changed, 0 insertions, 24 deletions
diff --git a/src/misc/getgrouplist.c b/src/misc/getgrouplist.c
deleted file mode 100644
index c9a8f090..00000000
--- a/src/misc/getgrouplist.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#define _GNU_SOURCE
-#include <grp.h>
-#include <string.h>
-#include <limits.h>
-
-int getgrouplist(const char *user, gid_t gid, gid_t *groups, int *ngroups)
-{
- size_t n, i;
- struct group *gr;
- if (*ngroups<1) return -1;
- n = *ngroups;
- *groups++ = gid;
- *ngroups = 1;
-
- setgrent();
- while ((gr = getgrent()) && *ngroups < INT_MAX) {
- for (i=0; gr->gr_mem[i] && strcmp(user, gr->gr_mem[i]); i++);
- if (!gr->gr_mem[i]) continue;
- if (++*ngroups <= n) *groups++ = gr->gr_gid;
- }
- endgrent();
-
- return *ngroups > n ? -1 : *ngroups;
-}