Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
how to get access to initgroups in python < 2.7
import os
from ctypes import CDLL, get_errno, c_char_p, c_int
libc = CDLL(None, use_errno=True)
def errcheck(result, func, arguments):
if result != 0:
e = get_errno()
raise OSError(e, os.strerror(e))
initgroups = libc.initgroups
initgroups.argtypes = [c_char_p, c_int]
initgroups.restype = c_int
initgroups.errcheck = errcheck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment