From ad3862d76c583f9ec623758344165da11cef8c62 Mon Sep 17 00:00:00 2001 From: Bob Hepple Date: Tue, 16 May 2017 13:01:45 +1000 Subject: [PATCH] Support python26 - os.initgroups() os.initgroups() is new in python27 see https://github.com/python-diamond/Diamond/issues/638 --- bin/diamond | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/diamond b/bin/diamond index 74ef0ed6a..f59e7d41f 100755 --- a/bin/diamond +++ b/bin/diamond @@ -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