]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Allow overriding min UID with AUTORANDR_UID_MIN env var.
authorutf8please <utf8please@users.noreply.github.com>
Mon, 9 May 2022 05:10:40 +0000 (22:10 -0700)
committerutf8please <utf8please@users.noreply.github.com>
Mon, 9 May 2022 05:10:40 +0000 (22:10 -0700)
autorandr.py

index b7940bc23c4eeaa5d6926118678298d82fcde914..e7b87020d9c1ac3c6607949a6d5fedf0a4c1614d 100755 (executable)
@@ -1198,6 +1198,16 @@ def dispatch_call_to_sessions(argv):
             sys.exit(1)
         os.waitpid(child_pid, 0)
 
+    # The following line assumes that user accounts start at 1000 and that no
+    # one works using the root or another system account. This is rather
+    # restrictive, but de facto default. If this breaks your use case, set the
+    # env var AUTORANDR_UID_MIN as appropriate. (Alternatives would be to use
+    # the UID_MIN from /etc/login.defs or FIRST_UID from /etc/adduser.conf; but
+    # effectively, both values aren't binding in any way.)
+    uid_min = 1000
+    if 'AUTORANDR_UID_MIN' in os.environ:
+      uid_min = int(os.environ['AUTORANDR_UID_MIN'])
+
     for directory in os.listdir("/proc"):
         directory = os.path.join("/proc/", directory)
         if not os.path.isdir(directory):
@@ -1207,13 +1217,7 @@ def dispatch_call_to_sessions(argv):
             continue
         uid = os.stat(environ_file).st_uid
 
-        # The following line assumes that user accounts start at 1000 and that
-        # no one works using the root or another system account. This is rather
-        # restrictive, but de facto default. Alternatives would be to use the
-        # UID_MIN from /etc/login.defs or FIRST_UID from /etc/adduser.conf;
-        # but effectively, both values aren't binding in any way.
-        # If this breaks your use case, please file a bug on Github.
-        if uid < 1000:
+        if uid < uid_min:
             continue
 
         process_environ = {}