summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-02-21 17:57:55 +0100
committerLennart Poettering <lennart@poettering.net>2017-02-21 21:55:43 +0100
commit48a601fe5de8aa0d89ba6dadde168769fa7ce992 (patch)
tree10f9b703d9dd770b6fc354735bd8ad1b6817f0b4 /src/basic
parent525872bfab49ce44390a29f322816ae951a4bc38 (diff)
log: never log into foreign fd #2 in PID 1 or its pre-execve() children
Fixes: #5401
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/log.c7
-rw-r--r--src/basic/log.h1
2 files changed, 7 insertions, 1 deletions
diff --git a/src/basic/log.c b/src/basic/log.c
index e6d2d61d72..36efc9ac7d 100644
--- a/src/basic/log.c
+++ b/src/basic/log.c
@@ -72,6 +72,7 @@ static bool show_color = false;
static bool show_location = false;
static bool upgrade_syslog_to_journal = false;
+static bool always_reopen_console = false;
/* Akin to glibc's __abort_msg; which is private and we hence cannot
* use here. */
@@ -95,7 +96,7 @@ static int log_open_console(void) {
if (console_fd >= 0)
return 0;
- if (getpid() == 1) {
+ if (always_reopen_console) {
console_fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC);
if (console_fd < 0)
return console_fd;
@@ -1171,3 +1172,7 @@ int log_syntax_internal(
unit_fmt, unit,
NULL);
}
+
+void log_set_always_reopen_console(bool b) {
+ always_reopen_console = b;
+}
diff --git a/src/basic/log.h b/src/basic/log.h
index 9cacbb6b70..72714e02e5 100644
--- a/src/basic/log.h
+++ b/src/basic/log.h
@@ -220,6 +220,7 @@ LogTarget log_target_from_string(const char *s) _pure_;
void log_received_signal(int level, const struct signalfd_siginfo *si);
void log_set_upgrade_syslog_to_journal(bool b);
+void log_set_always_reopen_console(bool b);
int log_syntax_internal(
const char *unit,