From 1598d6bc559b766e1fde83d9d9e4929d2694b090 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Wed, 21 Jan 2009 16:04:24 +1100 Subject: - (djm) [uidswap.c] bz#1412: Support >16 supplemental groups in OS X. Patch based on one from vgiffin AT apple.com; ok dtucker@ --- uidswap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'uidswap.c') diff --git a/uidswap.c b/uidswap.c index 91d878c30..837648396 100644 --- a/uidswap.c +++ b/uidswap.c @@ -233,6 +233,16 @@ permanently_set_uid(struct passwd *pw) fatal("setgid %u: %.100s", (u_int)pw->pw_gid, strerror(errno)); #endif +#ifdef __APPLE__ + /* + * OS X requires initgroups after setgid to opt back into + * memberd support for >16 supplemental groups. + */ + if (initgroups(pw->pw_name, pw->pw_gid) < 0) + fatal("initgroups %.100s %u: %.100s", + pw->pw_name, (u_int)pw->pw_gid, strerror(errno)); +#endif + #if defined(HAVE_SETRESUID) && !defined(BROKEN_SETRESUID) if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) < 0) fatal("setresuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno)); -- cgit v1.2.3