]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
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)
committerLennart Poettering <lennart@poettering.net>
Thu, 4 Jan 2018 12:27:27 +0000 (13:27 +0100)
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-ask-password-agent.c
src/shared/spawn-polkit-agent.c

index 18c8f6c18c360f0c6bba90af2a570f6eb68d89b9..d26fa0e6fbe28b1541e918fec59d7dd2470dda62 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 17785fd15375b2edb91593fa2d426d5bc9524ad5..f78167c25c97008b8b168753370229fd4a94fd3d 100644 (file)
@@ -40,6 +40,9 @@ int ask_password_agent_open(void) {
         if (!isatty(STDIN_FILENO))
                 return 0;
 
+        if (!is_main_thread())
+                return -EPERM;
+
         r = fork_agent("(sd-askpwagent)",
                        NULL, 0,
                        &agent_pid,
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;