summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/src/misc/initgroups.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc-top-half/musl/src/misc/initgroups.c')
-rw-r--r--libc-top-half/musl/src/misc/initgroups.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/misc/initgroups.c b/libc-top-half/musl/src/misc/initgroups.c
new file mode 100644
index 0000000..922a958
--- /dev/null
+++ b/libc-top-half/musl/src/misc/initgroups.c
@@ -0,0 +1,11 @@
+#define _GNU_SOURCE
+#include <grp.h>
+#include <limits.h>
+
+int initgroups(const char *user, gid_t gid)
+{
+ gid_t groups[NGROUPS_MAX];
+ int count = NGROUPS_MAX;
+ if (getgrouplist(user, gid, groups, &count) < 0) return -1;
+ return setgroups(count, groups);
+}