From 0b2ce70ea445009e430da6cea8f9b4246b7a0b8d Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Mar 17 2023 08:10:53 +0000 Subject: import systemd-239-74.el8_8 --- diff --git a/SOURCES/0902-journald-server-always-create-state-file-in-signal-h.patch b/SOURCES/0902-journald-server-always-create-state-file-in-signal-h.patch new file mode 100644 index 0000000..b09df96 --- /dev/null +++ b/SOURCES/0902-journald-server-always-create-state-file-in-signal-h.patch @@ -0,0 +1,38 @@ +From 47cc8f7e1d153e576f146d309b4043739997a673 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Mon, 13 Mar 2023 14:22:28 +0100 +Subject: [PATCH] journald-server: always create state file in signal handler + +`journalctl --flush` waits on that file, so we must create if even if +nothing has really happened. + +RHEL-only + +Resolves: #2174645 +--- + src/journal/journald-server.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c +index 279a32768c..c72cb68095 100644 +--- a/src/journal/journald-server.c ++++ b/src/journal/journald-server.c +@@ -1188,6 +1188,7 @@ int server_process_datagram(sd_event_source *es, int fd, uint32_t revents, void + + static int dispatch_sigusr1(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) { + Server *s = userdata; ++ int r; + + assert(s); + +@@ -1197,6 +1198,10 @@ static int dispatch_sigusr1(sd_event_source *es, const struct signalfd_siginfo * + server_sync(s); + server_vacuum(s, false); + ++ r = touch("/run/systemd/journal/flushed"); ++ if (r < 0) ++ log_warning_errno(r, "Failed to touch /run/systemd/journal/flushed, ignoring: %m"); ++ + server_space_usage_message(s, NULL); + return 0; + } diff --git a/SOURCES/0903-journald-server-move-relinquish-code-into-function.patch b/SOURCES/0903-journald-server-move-relinquish-code-into-function.patch new file mode 100644 index 0000000..46f057d --- /dev/null +++ b/SOURCES/0903-journald-server-move-relinquish-code-into-function.patch @@ -0,0 +1,62 @@ +From 7a7b0c4ec7a5595a44d9c70d8270b0724a8b8c45 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Mon, 13 Mar 2023 14:31:38 +0100 +Subject: [PATCH] journald-server: move relinquish code into function + +No functional change, just refactoring. + +RHEL-only + +Related: #2174645 +--- + src/journal/journald-server.c | 23 ++++++++++++++++------- + 1 file changed, 16 insertions(+), 7 deletions(-) + +diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c +index c72cb68095..aa70db95cc 100644 +--- a/src/journal/journald-server.c ++++ b/src/journal/journald-server.c +@@ -1258,20 +1258,16 @@ static int dispatch_sigrtmin1(sd_event_source *es, const struct signalfd_siginfo + return 0; + } + +- +-static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) { +- Server *s = userdata; ++static void relinquish_var(Server *s) { + int r; + + assert(s); + + if (s->storage == STORAGE_NONE) +- return 0; ++ return; + + if (s->runtime_journal && !s->system_journal) +- return 0; +- +- log_debug("Received request to relinquish /var from PID " PID_FMT, si->ssi_pid); ++ return; + + (void) system_journal_open(s, false, true); + +@@ -1286,6 +1282,19 @@ static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo + if (r < 0) + log_warning_errno(r, "Failed to write /run/systemd/journal/relinquished, ignoring: %m"); + ++ return; ++} ++ ++static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) { ++ Server *s = userdata; ++ ++ assert(s); ++ assert(si); ++ ++ log_debug("Received request to relinquish /var from PID " PID_FMT, si->ssi_pid); ++ ++ relinquish_var(s); ++ + return 0; + } + diff --git a/SOURCES/0904-journald-server-always-touch-state-file-in-signal-ha.patch b/SOURCES/0904-journald-server-always-touch-state-file-in-signal-ha.patch new file mode 100644 index 0000000..40267b7 --- /dev/null +++ b/SOURCES/0904-journald-server-always-touch-state-file-in-signal-ha.patch @@ -0,0 +1,58 @@ +From 980add7d84084a474c6c604c0670743c2d1e624c Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Mon, 13 Mar 2023 14:32:20 +0100 +Subject: [PATCH] journald-server: always touch state file in signal handler + +`journalctl --relinquish-var` waits on that file, so we must create if +even if nothing has really happened. + +RHEL-only + +Related: #2174645 +--- + src/journal/journald-server.c | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c +index aa70db95cc..4788ff78bb 100644 +--- a/src/journal/journald-server.c ++++ b/src/journal/journald-server.c +@@ -1259,8 +1259,6 @@ static int dispatch_sigrtmin1(sd_event_source *es, const struct signalfd_siginfo + } + + static void relinquish_var(Server *s) { +- int r; +- + assert(s); + + if (s->storage == STORAGE_NONE) +@@ -1278,15 +1276,15 @@ static void relinquish_var(Server *s) { + if (unlink("/run/systemd/journal/flushed") < 0 && errno != ENOENT) + log_warning_errno(errno, "Failed to unlink /run/systemd/journal/flushed, ignoring: %m") ; + +- r = write_timestamp_file_atomic("/run/systemd/journal/relinquished", now(CLOCK_MONOTONIC)); +- if (r < 0) +- log_warning_errno(r, "Failed to write /run/systemd/journal/relinquished, ignoring: %m"); ++ /* NOTE: We don't create our own state file here, because dispatch_sigrtmin2() has to do it anyway. ++ * But if this function is ever called from another place, the creation must be done here too. */ + + return; + } + + static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) { + Server *s = userdata; ++ int r; + + assert(s); + assert(si); +@@ -1295,6 +1293,10 @@ static int dispatch_sigrtmin2(sd_event_source *es, const struct signalfd_siginfo + + relinquish_var(s); + ++ r = write_timestamp_file_atomic("/run/systemd/journal/relinquished", now(CLOCK_MONOTONIC)); ++ if (r < 0) ++ log_warning_errno(r, "Failed to write /run/systemd/journal/relinquished, ignoring: %m"); ++ + return 0; + } + diff --git a/SPECS/systemd.spec b/SPECS/systemd.spec index 5f644f6..da5b57f 100644 --- a/SPECS/systemd.spec +++ b/SPECS/systemd.spec @@ -13,7 +13,7 @@ Name: systemd Url: http://www.freedesktop.org/wiki/Software/systemd Version: 239 -Release: 73%{?dist} +Release: 74%{?dist} # For a breakdown of the licensing, see README License: LGPLv2+ and MIT and GPLv2+ Summary: System and Service Manager @@ -951,6 +951,9 @@ Patch0898: 0898-journald-rework-pid-change-handling.patch Patch0899: 0899-test-Add-a-test-case-for-15654.patch Patch0900: 0900-test-Stricter-test-case-for-15654-Add-more-checks.patch Patch0901: 0901-man-document-the-new-_LINE_BREAK-type.patch +Patch0902: 0902-journald-server-always-create-state-file-in-signal-h.patch +Patch0903: 0903-journald-server-move-relinquish-code-into-function.patch +Patch0904: 0904-journald-server-always-touch-state-file-in-signal-ha.patch %ifarch %{ix86} x86_64 aarch64 %global have_gnu_efi 1 @@ -1581,6 +1584,11 @@ fi %files tests -f .file-list-tests %changelog +* Tue Mar 14 2023 systemd maintenance team - 239-74 +- journald-server: always create state file in signal handler (#2174645) +- journald-server: move relinquish code into function (#2174645) +- journald-server: always touch state file in signal handler (#2174645) + * Mon Feb 27 2023 systemd maintenance team - 239-73 - journald: add API to move logging from /var to /run again (#1873540) - journalctl: add new --relinquish and --smart-relinquish options (#1873540)