diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-02-21 17:57:55 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-02-21 21:55:43 +0100 |
commit | 48a601fe5de8aa0d89ba6dadde168769fa7ce992 (patch) | |
tree | 10f9b703d9dd770b6fc354735bd8ad1b6817f0b4 /src/core | |
parent | 525872bfab49ce44390a29f322816ae951a4bc38 (diff) |
log: never log into foreign fd #2 in PID 1 or its pre-execve() children
Fixes: #5401
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/main.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/core/main.c b/src/core/main.c index 3c6b18229c..bcf9ea5f25 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1414,10 +1414,17 @@ int main(int argc, char *argv[]) { log_set_upgrade_syslog_to_journal(true); - /* Disable the umask logic */ - if (getpid() == 1) + if (getpid() == 1) { + /* Disable the umask logic */ umask(0); + /* Always reopen /dev/console when running as PID 1 or one of its pre-execve() children. This is + * important so that we never end up logging to any foreign stderr, for example if we have to log in a + * child process right before execve()'ing the actual binary, at a point in time where socket + * activation stderr/stdout area already set up. */ + log_set_always_reopen_console(true); + } + if (getpid() == 1 && detect_container() <= 0) { /* Running outside of a container as PID 1 */ |