Index: twisted/python/util.py
===================================================================
--- twisted/python/util.py	(revision 26969)
+++ twisted/python/util.py	(working copy)
@@ -569,9 +569,29 @@
     L2.sort()
     return [e[2] for e in L2]
 
-if pwd is None or grp is None or setgroups is None or getgroups is None:
+
+try:
+    from ctypes import c_int, c_char_p, cdll
+    from ctypes.util import find_library
+    hasCtypes = True
+except ImportError:
+    hasCtypes = False
+
+if sys.platform == "darwin" and hasCtypes:
+    import pwd
+    libc = cdll.LoadLibrary(find_library("libc"))
     def initgroups(uid, primaryGid):
         """
+        Call initgroups with ctypes.
+        """
+        c_gid = c_int(primaryGid)
+        username = pwd.getpwuid(uid)[0]
+        c_username = c_char_p(username)
+        return libc.initgroups(c_username, c_gid)
+
+elif pwd is None or grp is None or setgroups is None or getgroups is None:
+    def initgroups(uid, primaryGid):
+        """
         Do nothing.
 
         Underlying platform support require to manipulate groups is missing.
