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.
This commit is contained in:
Lennart Poettering
2018-01-04 13:27:27 +01:00
parent b4a343112e
commit 85afeae88c
3 changed files with 9 additions and 0 deletions
+3
View 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");
+3
View 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,
+3
View 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;