From 46932031657dc5907d3d0628afde3717bedcd37a Mon Sep 17 00:00:00 2001 From: Phillip Berndt Date: Fri, 9 Oct 2020 16:16:14 +0200 Subject: [PATCH] Make setgroups() behaviour Python 2 compatible This fixes backwards compatibility of the change --- autorandr.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autorandr.py b/autorandr.py index a2c6f82..c517c48 100755 --- a/autorandr.py +++ b/autorandr.py @@ -1101,7 +1101,11 @@ def dispatch_call_to_sessions(argv): # 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) -- 2.39.2