]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Make setgroups() behaviour Python 2 compatible
authorPhillip Berndt <phillip.berndt@googlemail.com>
Fri, 9 Oct 2020 14:16:14 +0000 (16:16 +0200)
committerPhillip Berndt <phillip.berndt@googlemail.com>
Fri, 9 Oct 2020 14:16:51 +0000 (16:16 +0200)
This fixes backwards compatibility of the change

autorandr.py

index a2c6f8274e17c7782e95375419a848254b5e1010..c517c48431c91f5f46f860837ebc20b2f6a26d73 100755 (executable)
@@ -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)