Instead of just relying on setgroups, fallback to initgroups() when necessary.

setgroups() can only handle up to NGROUPS_MAX groups. On OS X that value is
very low, only 16.