summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-09-02 18:35:03 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-09-02 20:06:18 +0200
commitf1ee066840eea748ad4074ac2bc859bb897953b9 (patch)
tree8d5a5e2ed9a47a13baa1d9c8c9c978890d97cb67
parentMerge pull request #24536 from yuwata/dissect-take-loop-device (diff)
downloadsystemd-f1ee066840eea748ad4074ac2bc859bb897953b9.tar.xz
systemd-f1ee066840eea748ad4074ac2bc859bb897953b9.zip
log: don't attempt to duplicate closed fd
if the console fd is not open we shouldn#t try to move it out of the 0…2 range. Fixes: #24535 Alternative-for: #24537
-rw-r--r--src/basic/log.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/basic/log.c b/src/basic/log.c
index cac17a76f4..c5e16d669b 100644
--- a/src/basic/log.c
+++ b/src/basic/log.c
@@ -1460,7 +1460,7 @@ int log_dup_console(void) {
/* Duplicate the fd we use for fd logging if it's < 3 and use the copy from now on. This call is useful
* whenever we want to continue logging through the original fd, but want to rearrange stderr. */
- if (console_fd >= 3)
+ if (console_fd < 0 || console_fd >= 3)
return 0;
copy = fcntl(console_fd, F_DUPFD_CLOEXEC, 3);