diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2021-03-20 18:12:14 +0300 |
---|---|---|
committer | Sergey Bugaev <bugaevc@gmail.com> | 2021-03-22 19:34:07 +0300 |
commit | 7e0ed2e9a2fea20b21d17b374fdb709589e02008 (patch) | |
tree | 08c437dd23d819e6c3c290a987df3b93ebc344d9 /src/home | |
parent | 0e557eef37c9ebcc8f5c19fc6fc44b6fd617cc5d (diff) | |
download | systemd-7e0ed2e9a2fea20b21d17b374fdb709589e02008.tar.gz |
tree-wide: reopen log after fork when needed
This follows up on 0b1f3c768ce1bd1490a5e53f539976dcef8ca765, adding more places
where we should reopen the log after forking with FORK_CLOSE_ALL_FDS.
When immediately calling exec in the child, prefer to explicitly reopen the log
after exec fails. In other cases, just use FORK_REOPEN_LOG.
Diffstat (limited to 'src/home')
-rw-r--r-- | src/home/homed-home.c | 6 | ||||
-rw-r--r-- | src/home/homework-fscrypt.c | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/home/homed-home.c b/src/home/homed-home.c index 5a777e88ef..b0c5ce4232 100644 --- a/src/home/homed-home.c +++ b/src/home/homed-home.c @@ -1007,7 +1007,7 @@ static int home_start_work(Home *h, const char *verb, UserRecord *hr, UserRecord r = safe_fork_full("(sd-homework)", (int[]) { stdin_fd, stdout_fd }, 2, - FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DEATHSIG|FORK_LOG, &pid); + FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DEATHSIG|FORK_LOG|FORK_REOPEN_LOG, &pid); if (r < 0) return r; if (r == 0) { @@ -1838,7 +1838,9 @@ int home_killall(Home *h) { assert(h->uid > 0); /* We never should be UID 0 */ /* Let's kill everything matching the specified UID */ - r = safe_fork("(sd-killer)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DEATHSIG|FORK_WAIT|FORK_LOG, NULL); + r = safe_fork("(sd-killer)", + FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DEATHSIG|FORK_WAIT|FORK_LOG|FORK_REOPEN_LOG, + NULL); if (r < 0) return r; if (r == 0) { diff --git a/src/home/homework-fscrypt.c b/src/home/homework-fscrypt.c index d0676f8ae6..037e4853fd 100644 --- a/src/home/homework-fscrypt.c +++ b/src/home/homework-fscrypt.c @@ -324,7 +324,9 @@ int home_prepare_fscrypt( /* Also install the access key in the user's own keyring */ if (uid_is_valid(h->uid)) { - r = safe_fork("(sd-addkey)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DEATHSIG|FORK_LOG|FORK_WAIT, NULL); + r = safe_fork("(sd-addkey)", + FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DEATHSIG|FORK_LOG|FORK_WAIT|FORK_REOPEN_LOG, + NULL); if (r < 0) return log_error_errno(r, "Failed install encryption key in user's keyring: %m"); if (r == 0) { |