systemd/backport-journalctl-never-fail-at-flushing-when-the-flushed-f.patch

45 lines
1.6 KiB
Diff

From dc331f4c9268d17a66f4393cfd0dba14c7022d41 Mon Sep 17 00:00:00 2001
From: Franck Bui <fbui@suse.com>
Date: Wed, 4 Aug 2021 11:20:07 +0200
Subject: [PATCH] journalctl: never fail at flushing when the flushed flag is
set
Even if journald was not running, flushing the volatile journal used to work if
the journal was already flushed (ie the flushed flag
/run/systemd/journald/flushed was created).
However since commit 4f413af2a0a, this behavior changed and now '--flush' fails
because it tries to contact journald without checking the presence of the
flushed flag anymore.
This patch restores the previous behavior since there's no reason to fail when
journalctl can figure out that the flush is not necessary.
(cherry picked from commit f6fca35e642a112e80cc9bddb9a2b4805ad40df2)
Conflict:NA
Reference:https://github.com/systemd/systemd/commit/dc331f4c9268d17a66f4393cfd0dba14c7022d41
---
src/journal/journalctl.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index c8fb726d42..3eac97510d 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -2074,6 +2074,11 @@ static int simple_varlink_call(const char *option, const char *method) {
}
static int flush_to_var(void) {
+ if (access("/run/systemd/journal/flushed", F_OK) >= 0)
+ return 0; /* Already flushed, no need to contact journald */
+ if (errno != ENOENT)
+ return log_error_errno(errno, "Unable to check for existence of /run/systemd/journal/flushed: %m");
+
return simple_varlink_call("--flush", "io.systemd.Journal.FlushToVar");
}
--
2.33.0