From: Phillip Berndt Date: Fri, 9 Oct 2020 14:16:14 +0000 (+0200) Subject: Make setgroups() behaviour Python 2 compatible X-Git-Tag: 1.11~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=46932031657dc5907d3d0628afde3717bedcd37a;p=deb_pkgs%2Fautorandr.git Make setgroups() behaviour Python 2 compatible This fixes backwards compatibility of the change --- 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)