Skip to content

Commit

Permalink
Support python26 - os.initgroups()
Browse files Browse the repository at this point in the history
os.initgroups() is new in python27

see python-diamond#638
  • Loading branch information
bhepple authored May 16, 2017
1 parent 56d0cd1 commit ad3862d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bin/diamond
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,14 @@ def main():
try:
if gid != -1 and uid != -1:
# Manually set the groups since they aren't set by default
os.initgroups(pwd.getpwuid(uid).pw_name, gid)

# Python 2.7+
if hasattr(os, 'initgroups'):
os.initgroups(user, gid)
# Python 2.6
else:
os.setgroups([e.gr_gid for e in grp.getgrall()
if user in e.gr_mem] + [gid])

if gid != -1 and os.getgid() != gid:
# Set GID
Expand Down

0 comments on commit ad3862d

Please sign in to comment.