chiark / gitweb /
pager,agent: insist that we are called from the main thread
authorLennart Poettering <lennart@poettering.net>
Fri, 29 Dec 2017 17:13:38 +0000 (18:13 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:49:52 +0000 (07:49 +0200)
We maintain static process-wide variables in these subsystems without
locking, hence let's refuse operation unless we are called from the main
thread (which we do anyway) just as a safety precaution.

src/shared/pager.c
src/shared/spawn-polkit-agent.c

index b34cf2c005056c65aa00bc0ad3ec9153d9320fb4..7a19d4bb1970e2a878a175fb4f25b36b6bcaf0ca 100644 (file)
@@ -73,6 +73,9 @@ int pager_open(bool no_pager, bool jump_to_end) {
         if (terminal_is_dumb())
                 return 0;
 
+        if (!is_main_thread())
+                return -EPERM;
+
         pager = getenv("SYSTEMD_PAGER");
         if (!pager)
                 pager = getenv("PAGER");
index 886248b9f97b802671d10d595dd56791f27f426b..3c93c79cebd8e12d26fa0dacb77b27c9e3cae363 100644 (file)
@@ -52,6 +52,9 @@ int polkit_agent_open(void) {
         if (!isatty(STDIN_FILENO))
                 return 0;
 
+        if (!is_main_thread())
+                return -EPERM;
+
         if (pipe2(pipe_fd, 0) < 0)
                 return -errno;