Skip to content

Instantly share code, notes, and snippets.

@clayg
Created February 6, 2012 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clayg/1755433 to your computer and use it in GitHub Desktop.
Save clayg/1755433 to your computer and use it in GitHub Desktop.
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