mirror of
https://github.com/clearlinux/systemd-stable.git
synced 2026-10-16 21:30:52 +00:00
execute: avoid logging to closed fds
Several functions called from the "sd(EXEC)" process try to log messages when all the file descriptors are already closed, including the logging ones. The logging functions do not expect their fds to be closed and they hit an assertion failure. The failure wants to be logged too, so there is an infinite recursion, ended by a SIGSEGV. When we close all fds, we must let log.c know about it.
This commit is contained in:
@@ -1016,6 +1016,7 @@ int exec_spawn(ExecCommand *command,
|
||||
/* Close sockets very early to make sure we don't
|
||||
* block init reexecution because it cannot bind its
|
||||
* sockets */
|
||||
log_forget_fds();
|
||||
if (close_all_fds(socket_fd >= 0 ? &socket_fd : fds,
|
||||
socket_fd >= 0 ? 1 : n_fds) < 0) {
|
||||
r = EXIT_FDS;
|
||||
|
||||
@@ -237,6 +237,10 @@ void log_close(void) {
|
||||
log_close_syslog();
|
||||
}
|
||||
|
||||
void log_forget_fds(void) {
|
||||
console_fd = kmsg_fd = syslog_fd = -1;
|
||||
}
|
||||
|
||||
void log_set_max_level(int level) {
|
||||
assert((level & LOG_PRIMASK) == level);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user