# so it should be safe. Also, note that since the environment
# is taken from a process owned by the user, reusing it should
# not leak any information.
- os.setgroups(os.getgrouplist(pwent.pw_name, pwent.pw_gid))
+ try:
+ os.setgroups(os.getgrouplist(pwent.pw_name, pwent.pw_gid))
+ except AttributeError:
+ # Python 2 doesn't have getgrouplist
+ os.setgroups([])
os.setresgid(pwent.pw_gid, pwent.pw_gid, pwent.pw_gid)
os.setresuid(pwent.pw_uid, pwent.pw_uid, pwent.pw_uid)
os.chdir(pwent.pw_dir)