def setgroups(groups):
 max_groups = None
 try:
  max_groups = os.sysconf(u'SC_NGROUPS_MAX')
 except Exception:
  pass
 try:
  return _setgroups_hack(groups[:max_groups])
 except OSError as exc:
  if (exc.errno != errno.EPERM):
   raise
  if any(((group not in groups) for group in os.getgroups())):
   raise

def setgroups ( groups ) : max_groups = None try : max_groups = os . sysconf ( u'SC_NGROUPS_MAX' ) except Exception : pass try : return _setgroups_hack ( groups [ : max_groups ] ) except OSError as exc : if ( exc . errno != errno . EPERM ) : raise if any ( ( ( group not in groups ) for group in os . getgroups ( ) ) ) : raise
set active groups from a list of group ids .