From: Lennart Poettering Date: Fri, 29 Dec 2017 17:13:38 +0000 (+0100) Subject: pager,agent: insist that we are called from the main thread X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=6ee75904e748798e2138425abe37068ed0c7c8d7;p=elogind.git pager,agent: insist that we are called from the main thread 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. --- diff --git a/src/shared/pager.c b/src/shared/pager.c index b34cf2c00..7a19d4bb1 100644 --- a/src/shared/pager.c +++ b/src/shared/pager.c @@ -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"); diff --git a/src/shared/spawn-polkit-agent.c b/src/shared/spawn-polkit-agent.c index 886248b9f..3c93c79ce 100644 --- a/src/shared/spawn-polkit-agent.c +++ b/src/shared/spawn-polkit-agent.c @@ -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;