From 0a9e9b8180cef7a540e2fa00ace276f9a8622700 Mon Sep 17 00:00:00 2001 From: wangyuhang Date: Thu, 22 Feb 2024 19:43:11 +0800 Subject: [PATCH] sync patches from systemd community --- ...-to-control-whether-udev-complies-wi.patch | 15 +- ...-log-message-when-reloading-finishes.patch | 42 ++++++ ...x-fd-leak-in-dissected_image_acquire.patch | 63 ++++++++ ...ool-right-align-the-partition-number.patch | 37 +++++ ...ate-line_max-when-stdout-stream-stat.patch | 55 +++++++ ...ot-call-setlocale-when-multi-threade.patch | 45 ++++++ ...twork-neighbor-add-missing-OOM-check.patch | 32 ++++ ...move-draw_cylong-to-pretty-print.-ch.patch | 142 ++++++++++++++++++ backport-pid1-terminate-cylon-string.patch | 36 +++++ ...lve-do-not-trigger-assertion-on-exit.patch | 74 +++++++++ ...g-error-cause-assignment-to-log_debu.patch | 35 +++++ backport-test-add-test-for-draw_cylon.patch | 65 ++++++++ ...evice-is-a-zac-device-scsi-ID_SERIAL.patch | 67 +++++++++ systemd.spec | 43 +++++- 14 files changed, 736 insertions(+), 15 deletions(-) create mode 100644 backport-core-log-message-when-reloading-finishes.patch create mode 100644 backport-dissect-image-fix-fd-leak-in-dissected_image_acquire.patch create mode 100644 backport-dissect-tool-right-align-the-partition-number.patch create mode 100644 backport-journal-recalculate-line_max-when-stdout-stream-stat.patch create mode 100644 backport-locale-util-do-not-call-setlocale-when-multi-threade.patch create mode 100644 backport-network-neighbor-add-missing-OOM-check.patch create mode 100644 backport-pid1-move-draw_cylong-to-pretty-print.-ch.patch create mode 100644 backport-pid1-terminate-cylon-string.patch create mode 100644 backport-resolve-do-not-trigger-assertion-on-exit.patch create mode 100644 backport-resolve-fix-wrong-error-cause-assignment-to-log_debu.patch create mode 100644 backport-test-add-test-for-draw_cylon.patch create mode 100644 backport-udev-even-if-a-device-is-a-zac-device-scsi-ID_SERIAL.patch diff --git a/add-a-new-switch-to-control-whether-udev-complies-wi.patch b/add-a-new-switch-to-control-whether-udev-complies-wi.patch index c2bc744..85a6d42 100644 --- a/add-a-new-switch-to-control-whether-udev-complies-wi.patch +++ b/add-a-new-switch-to-control-whether-udev-complies-wi.patch @@ -12,9 +12,9 @@ Reason: Original revisions of the SAT (SCSI-ATA Translation) specification, --- src/shared/udev-util.c | 16 ++++++++++++++-- src/shared/udev-util.h | 5 +++-- - src/udev/ata_id/ata_id.c | 19 +++++++++++++++++-- + src/udev/ata_id/ata_id.c | 20 +++++++++++++++++--- src/udev/udevd.c | 3 ++- - 4 files changed, 36 insertions(+), 7 deletions(-) + 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/shared/udev-util.c b/src/shared/udev-util.c index f934fc1..2ff4a7c 100644 @@ -78,7 +78,7 @@ index 276686d..9695c64 100644 int device_wait_for_initialization(sd_device *device, const char *subsystem, usec_t deadline, sd_device **ret); diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c -index 1fc27f4..10a3464 100644 +index d0c5217..2dbe1ef 100644 --- a/src/udev/ata_id/ata_id.c +++ b/src/udev/ata_id/ata_id.c @@ -28,9 +28,13 @@ @@ -104,11 +104,12 @@ index 1fc27f4..10a3464 100644 errno = EIO; return -1; } -@@ -407,12 +411,23 @@ int main(int argc, char *argv[]) { +@@ -413,13 +417,23 @@ int main(int argc, char *argv[]) { { "help", no_argument, NULL, 'h' }, {} }; -+ int r; +- int peripheral_device_type = -1; ++ int r, peripheral_device_type = -1; log_set_target(LOG_TARGET_AUTO); - udev_parse_config(); @@ -130,10 +131,10 @@ index 1fc27f4..10a3464 100644 int option; diff --git a/src/udev/udevd.c b/src/udev/udevd.c -index 023fe55..34bc6ee 100644 +index 405a593..e78a28a 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c -@@ -2073,7 +2073,8 @@ int run_udevd(int argc, char *argv[]) { +@@ -2074,7 +2074,8 @@ int run_udevd(int argc, char *argv[]) { log_set_target(LOG_TARGET_AUTO); log_open(); diff --git a/backport-core-log-message-when-reloading-finishes.patch b/backport-core-log-message-when-reloading-finishes.patch new file mode 100644 index 0000000..04046fa --- /dev/null +++ b/backport-core-log-message-when-reloading-finishes.patch @@ -0,0 +1,42 @@ +From 6d3db6f092a6478ad8e0518e573c44a004021d3e Mon Sep 17 00:00:00 2001 +From: Luca Boccassi +Date: Wed, 8 Mar 2023 12:59:40 +0000 +Subject: [PATCH] core: log message when reloading finishes + +Reloading might be slow, especially when under memory pressure, and watchdogs +might be triggered. It is useful to have timestamped telemetry in the journal +to see how long a reload takes. + +(cherry picked from commit af2fb2f250e664973d947554414749e9b94d68a1) + +Conflict:code context adaptation and delete the print related to MANAGER_TIMESTAMP_UNITS_LOAD +Reference:https://github.com/systemd/systemd/commit/af2fb2f250e664973d947554414749e9b94d68a1 +--- + src/core/main.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/core/main.c b/src/core/main.c +index 4317365..a36b13d 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -1934,7 +1934,7 @@ static int invoke_main_loop( + LogTarget saved_log_target; + int saved_log_level; + +- log_info("Reloading."); ++ log_info("Reloading..."); + + /* First, save any overridden log level/target, then parse the configuration file, which might + * change the log level to new settings. */ +@@ -1959,6 +1959,8 @@ static int invoke_main_loop( + if (r < 0) + /* Reloading failed before the point of no return. Let's continue running as if nothing happened. */ + m->objective = MANAGER_OK; ++ else ++ log_info("Reloading finished."); + + break; + } +-- +2.33.0 + diff --git a/backport-dissect-image-fix-fd-leak-in-dissected_image_acquire.patch b/backport-dissect-image-fix-fd-leak-in-dissected_image_acquire.patch new file mode 100644 index 0000000..cbf39cb --- /dev/null +++ b/backport-dissect-image-fix-fd-leak-in-dissected_image_acquire.patch @@ -0,0 +1,63 @@ +From 87b473af799262ef7cbe71214045789c16d9ad9a Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 4 Dec 2023 18:21:23 +0100 +Subject: [PATCH] dissect-image: fix fd leak in + dissected_image_acquire_metadata() + +We have to go through the "finish" label to properly close all pipes in +the error path, so that we don't leak them. + +(cherry picked from commit 8d5e61db432932faa5b2d8531ab804bb4da4791d) +(cherry picked from commit f6cf899f1ed55f9ed140f1a4b57d6e27b973854b) +(cherry picked from commit 92479eb37614c0b7d9b83c686d8940ee2ea32a90) +(cherry picked from commit 053c90d59bc83592da3b74257c91e162c8cbd01a) + +Conflict:NA +Reference:https://github.com/systemd/systemd/commit/8d5e61db432932faa5b2d8531ab804bb4da4791d +--- + src/shared/dissect-image.c | 27 +++++++++++++++++---------- + 1 file changed, 17 insertions(+), 10 deletions(-) + +diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c +index 37dbf64d96..d2446deb0c 100644 +--- a/src/shared/dissect-image.c ++++ b/src/shared/dissect-image.c +@@ -3042,18 +3042,25 @@ int dissected_image_acquire_metadata(DissectedImage *m, DissectImageFlags extra_ + r = wait_for_terminate_and_check("(sd-dissect)", child, 0); + child = 0; + if (r < 0) +- return r; ++ goto finish; + + n = read(error_pipe[0], &v, sizeof(v)); +- if (n < 0) +- return -errno; +- if (n == sizeof(v)) +- return v; /* propagate error sent to us from child */ +- if (n != 0) +- return -EIO; +- +- if (r != EXIT_SUCCESS) +- return -EPROTO; ++ if (n < 0) { ++ r = -errno; ++ goto finish; ++ } ++ if (n == sizeof(v)) { ++ r = v; /* propagate error sent to us from child */ ++ goto finish; ++ } ++ if (n != 0) { ++ r = -EIO; ++ goto finish; ++ } ++ if (r != EXIT_SUCCESS) { ++ r = -EPROTO; ++ goto finish; ++ } + + free_and_replace(m->hostname, hostname); + m->machine_id = machine_id; +-- +2.33.0 + diff --git a/backport-dissect-tool-right-align-the-partition-number.patch b/backport-dissect-tool-right-align-the-partition-number.patch new file mode 100644 index 0000000..077481f --- /dev/null +++ b/backport-dissect-tool-right-align-the-partition-number.patch @@ -0,0 +1,37 @@ +From 45dcf01111b7441d962cf2df9f03b6b0d6635fd9 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 4 Dec 2023 18:07:18 +0100 +Subject: [PATCH] dissect-tool: right-align the partition number + +The right-alignment was applied to the wrong column, because neither +ee8e497d249ab2e2df92aa024274f5b817270114 nor +1474d7ac2d308204e599a2502a8b5625bca76bcc updated the column count as +they should have. + +(cherry picked from commit 748e87a7911813d64e34f2366df842b210a27f11) +(cherry picked from commit 8ff96162aa7e724fc0137afab9ad35ec662909df) +(cherry picked from commit 99fdfaa5076b530c02b6f87cd1ab23612ecd251a) +(cherry picked from commit 5794ad609c0bedb657d60823c516c5b32362fe25) + +Conflict:code context adaptation +Reference:https://github.com/systemd/systemd/commit/748e87a7911813d64e34f2366df842b210a27f11 +--- + src/dissect/dissect.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c +index 25ce3f9771..6ff8221c9a 100644 +--- a/src/dissect/dissect.c ++++ b/src/dissect/dissect.c +@@ -574,7 +574,7 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) { + return log_oom(); + + (void) table_set_empty_string(t, "-"); +- (void) table_set_align_percent(t, table_get_cell(t, 0, 7), 100); ++ (void) table_set_align_percent(t, table_get_cell(t, 0, 9), 100); + + for (PartitionDesignator i = 0; i < _PARTITION_DESIGNATOR_MAX; i++) { + DissectedPartition *p = m->partitions + i; +-- +2.33.0 + diff --git a/backport-journal-recalculate-line_max-when-stdout-stream-stat.patch b/backport-journal-recalculate-line_max-when-stdout-stream-stat.patch new file mode 100644 index 0000000..4f96380 --- /dev/null +++ b/backport-journal-recalculate-line_max-when-stdout-stream-stat.patch @@ -0,0 +1,55 @@ +From d63d5b5cd0a4a2010797b435a7fc981e4d94b05d Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Thu, 9 Nov 2023 13:24:57 +0100 +Subject: [PATCH] journal: recalculate line_max when stdout stream state + changes + +Otherwise we might still use the more restrictive limit when we get to +STDOUT_STREAM_RUNNING, causing unexpected line breaks in the journal +messages. + +Follow-up to: 80e9720616 +Resolves: #29916 + +(cherry picked from commit d603e3d58c77c66dc411c1c5b6575c45ea1d6a8d) +(cherry picked from commit 7a7e84b01581fbe31dc9518a40a05e30a61cf3db) +(cherry picked from commit 4090c12f1263a543b9116a695fa1892d86fbb22d) + +Conflict:NA +Reference:https://github.com/systemd/systemd/commit/d603e3d58c77c66dc411c1c5b6575c45ea1d6a8d +--- + src/journal/journald-stream.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c +index 9d8606f995..f2f3f0ac5b 100644 +--- a/src/journal/journald-stream.c ++++ b/src/journal/journald-stream.c +@@ -488,19 +488,21 @@ static int stdout_stream_scan( + LineBreak force_flush, + size_t *ret_consumed) { + +- size_t consumed = 0, line_max; ++ size_t consumed = 0; + int r; + + assert(s); + assert(p); + +- line_max = stdout_stream_line_max(s); + + for (;;) { + LineBreak line_break; + size_t skip, found; + char *end1, *end2; +- size_t tmp_remaining = MIN(remaining, line_max); ++ size_t tmp_remaining, line_max; ++ ++ line_max = stdout_stream_line_max(s); ++ tmp_remaining = MIN(remaining, line_max); + + end1 = memchr(p, '\n', tmp_remaining); + end2 = memchr(p, 0, end1 ? (size_t) (end1 - p) : tmp_remaining); +-- +2.33.0 + diff --git a/backport-locale-util-do-not-call-setlocale-when-multi-threade.patch b/backport-locale-util-do-not-call-setlocale-when-multi-threade.patch new file mode 100644 index 0000000..2aa06de --- /dev/null +++ b/backport-locale-util-do-not-call-setlocale-when-multi-threade.patch @@ -0,0 +1,45 @@ +From 4ae69c493f4cacfa73eed8c32948d3766c7d1f0a Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Thu, 23 Nov 2023 00:32:48 +0900 +Subject: [PATCH] locale-util: do not call setlocale() when multi-threaded + +Fixes #30141. + +(cherry picked from commit ca13432d600593b8eda76721118763b63746eb33) +(cherry picked from commit 6b1d188bd5a01dede2146fadd9b01c5690b7c7fc) +(cherry picked from commit 420adce67d5286bedf045d79f14872864268b7de) + +Conflict:NA +Reference:https://github.com/systemd/systemd/commit/ca13432d600593b8eda76721118763b63746eb33 +--- + src/basic/locale-util.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/src/basic/locale-util.c b/src/basic/locale-util.c +index d8518ec06a..fb3ec3a424 100644 +--- a/src/basic/locale-util.c ++++ b/src/basic/locale-util.c +@@ -17,6 +17,7 @@ + #include "fileio.h" + #include "hashmap.h" + #include "locale-util.h" ++#include "missing_syscall.h" + #include "path-util.h" + #include "set.h" + #include "string-table.h" +@@ -295,6 +296,12 @@ bool is_locale_utf8(void) { + if (cached_answer >= 0) + goto out; + ++ /* This function may be called from libsystemd, and setlocale() is not thread safe. Assuming yes. */ ++ if (gettid() != raw_getpid()) { ++ cached_answer = true; ++ goto out; ++ } ++ + if (!setlocale(LC_ALL, "")) { + cached_answer = true; + goto out; +-- +2.33.0 + diff --git a/backport-network-neighbor-add-missing-OOM-check.patch b/backport-network-neighbor-add-missing-OOM-check.patch new file mode 100644 index 0000000..5527b68 --- /dev/null +++ b/backport-network-neighbor-add-missing-OOM-check.patch @@ -0,0 +1,32 @@ +From 77f609d74b134fc93890aa57d5f1f8eb8e770e39 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Sun, 10 Dec 2023 16:03:52 +0900 +Subject: [PATCH] network/neighbor: add missing OOM check + +(cherry picked from commit be26893c85b7200d41440792928f5ebbf06fa8cb) +(cherry picked from commit 3411c8a42a60816187aa8dce7c4282af001473d6) +(cherry picked from commit 4abd97bc53d25cdb7948ed7065f6a62415fbec1d) +(cherry picked from commit 10b20d61b4cb2089464fffda11318576f0511455) + +Conflict:NA +Reference:https://github.com/systemd/systemd/commit/be26893c85b7200d41440792928f5ebbf06fa8cb +--- + src/network/networkd-neighbor.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/network/networkd-neighbor.c b/src/network/networkd-neighbor.c +index f0f78b9c4a..ee40a3ccc5 100644 +--- a/src/network/networkd-neighbor.c ++++ b/src/network/networkd-neighbor.c +@@ -502,6 +502,8 @@ int manager_rtnl_process_neighbor(sd_netlink *rtnl, sd_netlink_message *message, + } + + tmp = new0(Neighbor, 1); ++ if (!tmp) ++ return log_oom(); + + r = sd_rtnl_message_neigh_get_family(message, &tmp->family); + if (r < 0) { +-- +2.33.0 + diff --git a/backport-pid1-move-draw_cylong-to-pretty-print.-ch.patch b/backport-pid1-move-draw_cylong-to-pretty-print.-ch.patch new file mode 100644 index 0000000..18e2919 --- /dev/null +++ b/backport-pid1-move-draw_cylong-to-pretty-print.-ch.patch @@ -0,0 +1,142 @@ +From 9a56edb37b9a01e36a2fdf9d441b3bbded933878 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Wed, 22 Nov 2023 07:01:50 +0900 +Subject: [PATCH] pid1: move draw_cylong() to pretty-print.[ch] + +(cherry picked from commit d61a4dbba93a2b34dc85522e432c30ca152d4dda) +(cherry picked from commit f76318f2c9d1e0122640f378043427d0d200a008) +(cherry picked from commit adbcdc481cac36b6d50225bae6cb7bc3b16b32e9) + +Conflict:code context adaptation and add missing header file +Reference:https://github.com/systemd/systemd/commit/d61a4dbba93a2b34dc85522e432c30ca152d4dda +--- + src/core/manager.c | 39 +-------------------------------------- + src/shared/pretty-print.c | 36 ++++++++++++++++++++++++++++++++++++ + src/shared/pretty-print.h | 4 ++++ + 3 files changed, 41 insertions(+), 38 deletions(-) + +diff --git a/src/core/manager.c b/src/core/manager.c +index 6357d3b625..7446444add 100644 +--- a/src/core/manager.c ++++ b/src/core/manager.c +@@ -65,6 +65,7 @@ + #include "parse-util.h" + #include "path-lookup.h" + #include "path-util.h" ++#include "pretty-print.h" + #include "process-util.h" + #include "ratelimit.h" + #include "rlimit-util.h" +@@ -164,44 +165,6 @@ static void manager_watch_jobs_in_progress(Manager *m) { + (void) sd_event_source_set_description(m->jobs_in_progress_event_source, "manager-jobs-in-progress"); + } + +-#define CYLON_BUFFER_EXTRA (2*STRLEN(ANSI_RED) + STRLEN(ANSI_HIGHLIGHT_RED) + 2*STRLEN(ANSI_NORMAL)) +- +-static void draw_cylon(char buffer[], size_t buflen, unsigned width, unsigned pos) { +- char *p = buffer; +- +- assert(buflen >= CYLON_BUFFER_EXTRA + width + 1); +- assert(pos <= width+1); /* 0 or width+1 mean that the center light is behind the corner */ +- +- if (pos > 1) { +- if (pos > 2) +- p = mempset(p, ' ', pos-2); +- if (log_get_show_color()) +- p = stpcpy(p, ANSI_RED); +- *p++ = '*'; +- } +- +- if (pos > 0 && pos <= width) { +- if (log_get_show_color()) +- p = stpcpy(p, ANSI_HIGHLIGHT_RED); +- *p++ = '*'; +- } +- +- if (log_get_show_color()) +- p = stpcpy(p, ANSI_NORMAL); +- +- if (pos < width) { +- if (log_get_show_color()) +- p = stpcpy(p, ANSI_RED); +- *p++ = '*'; +- if (pos < width-1) +- p = mempset(p, ' ', width-1-pos); +- if (log_get_show_color()) +- p = stpcpy(p, ANSI_NORMAL); +- } +- +- *p = '\0'; +-} +- + static void manager_flip_auto_status(Manager *m, bool enable, const char *reason) { + assert(m); + +diff --git a/src/shared/pretty-print.c b/src/shared/pretty-print.c +index 98619c25d4..2d52ed3d83 100644 +--- a/src/shared/pretty-print.c ++++ b/src/shared/pretty-print.c +@@ -18,6 +18,43 @@ + #include "terminal-util.h" + #include "util.h" ++#include "memory-util.h" ++ ++void draw_cylon(char buffer[], size_t buflen, unsigned width, unsigned pos) { ++ char *p = buffer; ++ ++ assert(buflen >= CYLON_BUFFER_EXTRA + width + 1); ++ assert(pos <= width+1); /* 0 or width+1 mean that the center light is behind the corner */ ++ ++ if (pos > 1) { ++ if (pos > 2) ++ p = mempset(p, ' ', pos-2); ++ if (log_get_show_color()) ++ p = stpcpy(p, ANSI_RED); ++ *p++ = '*'; ++ } ++ ++ if (pos > 0 && pos <= width) { ++ if (log_get_show_color()) ++ p = stpcpy(p, ANSI_HIGHLIGHT_RED); ++ *p++ = '*'; ++ } ++ ++ if (log_get_show_color()) ++ p = stpcpy(p, ANSI_NORMAL); ++ ++ if (pos < width) { ++ if (log_get_show_color()) ++ p = stpcpy(p, ANSI_RED); ++ *p++ = '*'; ++ if (pos < width-1) ++ p = mempset(p, ' ', width-1-pos); ++ if (log_get_show_color()) ++ p = stpcpy(p, ANSI_NORMAL); ++ } ++ ++ *p = '\0'; ++} + + bool urlify_enabled(void) { + #if ENABLE_URLIFY + static int cached_urlify_enabled = -1; +diff --git a/src/shared/pretty-print.h b/src/shared/pretty-print.h +index 45644da67d..cf28860bb8 100644 +--- a/src/shared/pretty-print.h ++++ b/src/shared/pretty-print.h +@@ -4,6 +4,12 @@ + /* SPDX-License-Identifier: LGPL-2.1-or-later */ + #pragma once + ++#include "terminal-util.h" ++ ++#define CYLON_BUFFER_EXTRA (2*STRLEN(ANSI_RED) + STRLEN(ANSI_HIGHLIGHT_RED) + 2*STRLEN(ANSI_NORMAL)) ++ ++void draw_cylon(char buffer[], size_t buflen, unsigned width, unsigned pos); ++ + void print_separator(void); + + int file_url_from_path(const char *path, char **ret); +-- +2.33.0 + diff --git a/backport-pid1-terminate-cylon-string.patch b/backport-pid1-terminate-cylon-string.patch new file mode 100644 index 0000000..5750f9e --- /dev/null +++ b/backport-pid1-terminate-cylon-string.patch @@ -0,0 +1,36 @@ +From 1c3727108414e3167d5653f9e78430678f6707c8 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Wed, 22 Nov 2023 06:54:18 +0900 +Subject: [PATCH] pid1: terminate cylon string + +Fixes #30121. + +(cherry picked from commit 0fe9604359d6a40fe064dbb19161a9f26a4d4198) +(cherry picked from commit 337107883cc867a0cdabed4e1d06ba4f2b1cc63a) +(cherry picked from commit 449fdb3156f5b17f0dfd3c1cfcba028670e121b3) + +Conflict:NA +Reference:https://github.com/systemd/systemd/commit/0fe9604359d6a40fe064dbb19161a9f26a4d4198 +--- + src/core/manager.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/core/manager.c b/src/core/manager.c +index dbdee9053c..6357d3b625 100644 +--- a/src/core/manager.c ++++ b/src/core/manager.c +@@ -196,8 +196,10 @@ static void draw_cylon(char buffer[], size_t buflen, unsigned width, unsigned po + if (pos < width-1) + p = mempset(p, ' ', width-1-pos); + if (log_get_show_color()) +- strcpy(p, ANSI_NORMAL); ++ p = stpcpy(p, ANSI_NORMAL); + } ++ ++ *p = '\0'; + } + + static void manager_flip_auto_status(Manager *m, bool enable, const char *reason) { +-- +2.33.0 + diff --git a/backport-resolve-do-not-trigger-assertion-on-exit.patch b/backport-resolve-do-not-trigger-assertion-on-exit.patch new file mode 100644 index 0000000..c35b8dd --- /dev/null +++ b/backport-resolve-do-not-trigger-assertion-on-exit.patch @@ -0,0 +1,74 @@ +From 8620b35320c38b3b810687d26ba7a72379e41857 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Thu, 7 Dec 2023 14:28:12 +0900 +Subject: [PATCH] resolve: do not trigger assertion on exit + +By making assert_return() critical, we observe the following: +--- + Program received signal SIGABRT, Aborted. + 0x00007f01320b0884 in __pthread_kill_implementation () from /lib64/libc.so.6 + (gdb) bt + #0 0x00007f01320b0884 in __pthread_kill_implementation () + from /lib64/libc.so.6 + #1 0x00007f013205fafe in raise () from /lib64/libc.so.6 + #2 0x00007f013204887f in abort () from /lib64/libc.so.6 + #3 0x00007f01338d02d6 in log_assert_failed ( + text=0x7f01340009e0 "e->state != SD_EVENT_FINISHED", + file=0x7f0133fff403 "src/libsystemd/sd-event/sd-event.c", line=1399, + func=0x7f01340045a0 <__func__.148> "sd_event_add_time") + at ../src/basic/log.c:948 + #4 0x00007f01338d0457 in log_assert_failed_return ( + text=0x7f01340009e0 "e->state != SD_EVENT_FINISHED", + file=0x7f0133fff403 "src/libsystemd/sd-event/sd-event.c", line=1399, + func=0x7f01340045a0 <__func__.148> "sd_event_add_time") + at ../src/basic/log.c:967 + #5 0x00007f0133c7ed83 in sd_event_add_time (e=0x617000022280, + ret=0x610000007e98, clock=7, usec=24054941030, accuracy=0, + callback=0x4625b4 , userdata=0x610000007e40) + at ../src/libsystemd/sd-event/sd-event.c:1399 + #6 0x00007f0133c7f725 in sd_event_add_time_relative (e=0x617000022280, + ret=0x610000007e98, clock=7, usec=1000000, accuracy=0, + callback=0x4625b4 , userdata=0x610000007e40) + at ../src/libsystemd/sd-event/sd-event.c:1462 + #7 0x0000000000464cac in dns_scope_announce (scope=0x610000007e40, goodbye=true) at ../src/resolve/resolved-dns-scope.c:1530 + #8 0x0000000000504d08 in link_free (l=0x612000023d40) at ../src/resolve/resolved-link.c:83 + #9 0x000000000052dbbd in manager_free (m=0x619000000a80) at ../src/resolve/resolved-manager.c:697 + #10 0x0000000000562328 in manager_freep (p=0x7f012f800040) at ../src/resolve/resolved-manager.h:198 + #11 0x000000000056315a in run (argc=1, argv=0x7fff22b06468) at ../src/resolve/resolved.c:25 + #12 0x0000000000563284 in main (argc=1, argv=0x7fff22b06468) at ../src/resolve/resolved.c:99 +--- +Prompted by https://github.com/systemd/systemd/pull/30049#issuecomment-1844087965. + +(cherry picked from commit a4be4ad8abad36ae2ac5c73fc00f4467fbb06404) +(cherry picked from commit 390e9420e314635a4d9051b8786e15423f58c979) +(cherry picked from commit 3529defd553b0cfabac7957f956ee9dc69d064b3) +(cherry picked from commit 8e70e220a66019345b5fca26f60c2822e56d80f3) + +Conflict:NA +Reference:https://github.com/systemd/systemd/commit/a4be4ad8abad36ae2ac5c73fc00f4467fbb06404 +--- + src/resolve/resolved-dns-scope.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c +index 88830fb2c6..4085b01054 100644 +--- a/src/resolve/resolved-dns-scope.c ++++ b/src/resolve/resolved-dns-scope.c +@@ -1410,6 +1410,14 @@ int dns_scope_announce(DnsScope *scope, bool goodbye) { + if (scope->protocol != DNS_PROTOCOL_MDNS) + return 0; + ++ r = sd_event_get_state(scope->manager->event); ++ if (r < 0) ++ return log_debug_errno(r, "Failed to get event loop state: %m"); ++ ++ /* If this is called on exit, through manager_free() -> link_free(), then we cannot announce. */ ++ if (r == SD_EVENT_FINISHED) ++ return 0; ++ + /* Check if we're done with probing. */ + LIST_FOREACH(transactions_by_scope, t, scope->transactions) + if (DNS_TRANSACTION_IS_LIVE(t->state)) +-- +2.33.0 + diff --git a/backport-resolve-fix-wrong-error-cause-assignment-to-log_debu.patch b/backport-resolve-fix-wrong-error-cause-assignment-to-log_debu.patch new file mode 100644 index 0000000..a142d40 --- /dev/null +++ b/backport-resolve-fix-wrong-error-cause-assignment-to-log_debu.patch @@ -0,0 +1,35 @@ +From 2e0c83da1bbdc589579a14cc4e9fff40bd9896c1 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Sun, 10 Dec 2023 14:33:48 +0900 +Subject: [PATCH] resolve: fix wrong error cause assignment to + log_debug_errno() + +Fixes #30392. + +(cherry picked from commit fca212b0225e48097f3b6bd1f8c3a38bd9645040) +(cherry picked from commit b2a37030c1191ebd526781629986cd713330b234) +(cherry picked from commit 27dd6913d30ba09e371788fcea327e389ec122b0) +(cherry picked from commit a53032076cd7ee4c4ce6402b0f2701a6daafb4c3) + +Conflict:NA +Reference:https://github.com/systemd/systemd/commit/fca212b0225e48097f3b6bd1f8c3a38bd9645040 +--- + src/resolve/resolved-dns-stub.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/resolve/resolved-dns-stub.c b/src/resolve/resolved-dns-stub.c +index 22f20f31e9..11e24b8757 100644 +--- a/src/resolve/resolved-dns-stub.c ++++ b/src/resolve/resolved-dns-stub.c +@@ -775,7 +775,7 @@ static void dns_stub_query_complete(DnsQuery *query) { + + cname_result = dns_query_process_cname_one(q); + if (cname_result == -ELOOP) { /* CNAME loop, let's send what we already have */ +- log_debug_errno(r, "Detected CNAME loop, returning what we already have."); ++ log_debug("Detected CNAME loop, returning what we already have."); + (void) dns_stub_send_reply(q, q->answer_rcode); + break; + } +-- +2.33.0 + diff --git a/backport-test-add-test-for-draw_cylon.patch b/backport-test-add-test-for-draw_cylon.patch new file mode 100644 index 0000000..8ec4a99 --- /dev/null +++ b/backport-test-add-test-for-draw_cylon.patch @@ -0,0 +1,65 @@ +From 8189de64a396990ba6a7edc8fb408557da840c41 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Wed, 22 Nov 2023 08:26:14 +0900 +Subject: [PATCH] test: add test for draw_cylon() + +(cherry picked from commit fa3ab903f39c9986e1a86b6f7abf543dc1d4b43d) +(cherry picked from commit 7a52da5c329c6627aad99acadacab6e1e4d8ae80) +(cherry picked from commit b460406940dc6892355735255d919970f72d469c) + +Conflict:adapt to the current test case framework +Reference:https://github.com/systemd/systemd/commit/fa3ab903f39c9986e1a86b6f7abf543dc1d4b43d +--- + src/test/test-pretty-print.c | 29 +++++++++++++++++++++++++++++ + 1 file changed, 29 insertions(+) + +diff --git a/src/test/test-pretty-print.c b/src/test/test-pretty-print.c +index dbae34e..3a8d206 100644 +--- a/src/test/test-pretty-print.c ++++ b/src/test/test-pretty-print.c +@@ -11,6 +11,34 @@ + #include "strv.h" + #include "tests.h" + ++#define CYLON_WIDTH 6 ++ ++static void test_draw_cylon_one(unsigned pos) { ++ char buf[CYLON_WIDTH + CYLON_BUFFER_EXTRA + 1]; ++ ++ log_debug("/* %s(%u) */", __func__, pos); ++ ++ assert(pos <= CYLON_WIDTH + 1); ++ ++ memset(buf, 0xff, sizeof(buf)); ++ draw_cylon(buf, sizeof(buf), CYLON_WIDTH, pos); ++ assert_se(strlen(buf) < sizeof(buf)); ++} ++ ++static void test_draw_cylon(void) { ++ bool saved = log_get_show_color(); ++ ++ log_show_color(false); ++ for (unsigned i = 0; i <= CYLON_WIDTH + 1; i++) ++ test_draw_cylon_one(i); ++ ++ log_show_color(true); ++ for (unsigned i = 0; i <= CYLON_WIDTH + 1; i++) ++ test_draw_cylon_one(i); ++ ++ log_show_color(saved); ++} ++ + static void test_terminal_urlify(void) { + _cleanup_free_ char *formatted = NULL; + +@@ -36,6 +64,7 @@ int main(int argc, char *argv[]) { + + test_terminal_urlify(); + test_cat_files(); ++ test_draw_cylon(); + + print_separator(); + +-- +2.33.0 + diff --git a/backport-udev-even-if-a-device-is-a-zac-device-scsi-ID_SERIAL.patch b/backport-udev-even-if-a-device-is-a-zac-device-scsi-ID_SERIAL.patch new file mode 100644 index 0000000..1c14851 --- /dev/null +++ b/backport-udev-even-if-a-device-is-a-zac-device-scsi-ID_SERIAL.patch @@ -0,0 +1,67 @@ +From 8a86e15f07dd7030bfc31fb4944c24fb9a481fc5 Mon Sep 17 00:00:00 2001 +From: wangyuhang <524413304@qq.com> +Date: Tue, 16 Jan 2024 13:57:07 +0800 +Subject: [PATCH] udev: even if a device is a zac device, scsi-$ID_SERIAL will + be reserved for it (#30459) + +Conflict:code context adaptation and do not merge the changes to 60-persistent-storage.rules +Reference:https://github.com/systemd/systemd/commit/8a86e15f07dd7030bfc31fb4944c24fb9a481fc5 +--- + src/udev/ata_id/ata_id.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c +index 1fc27f4..49357e3 100644 +--- a/src/udev/ata_id/ata_id.c ++++ b/src/udev/ata_id/ata_id.c +@@ -310,7 +310,8 @@ static void disk_identify_fixup_uint16 (uint8_t identify[512], unsigned offset_w + */ + static int disk_identify(int fd, + uint8_t out_identify[512], +- int *out_is_packet_device) { ++ int *out_is_packet_device, ++ int *ret_peripheral_device_type) { + int ret; + uint8_t inquiry_buf[36]; + int peripheral_device_type; +@@ -384,6 +385,10 @@ static int disk_identify(int fd, + out: + if (out_is_packet_device) + *out_is_packet_device = is_packet_device; ++ ++ if (ret_peripheral_device_type) ++ *ret_peripheral_device_type = peripheral_device_type; ++ + return ret; + } + +@@ -407,6 +412,7 @@ int main(int argc, char *argv[]) { + { "help", no_argument, NULL, 'h' }, + {} + }; ++ int peripheral_device_type = -1; + + log_set_target(LOG_TARGET_AUTO); + udev_parse_config(); +@@ -445,7 +451,7 @@ int main(int argc, char *argv[]) { + return 1; + } + +- if (disk_identify(fd, identify.byte, &is_packet_device) == 0) { ++ if (disk_identify(fd, identify.byte, &is_packet_device, &peripheral_device_type) == 0) { + /* + * fix up only the fields from the IDENTIFY data that we are going to + * use and copy it into the hd_driveid struct for convenience +@@ -640,6 +646,9 @@ int main(int argc, char *argv[]) { + if (IN_SET(identify.wyde[0], 0x848a, 0x844a) || + (identify.wyde[83] & 0xc004) == 0x4004) + printf("ID_ATA_CFA=1\n"); ++ ++ if (peripheral_device_type >= 0) ++ printf("ID_ATA_PERIPHERAL_DEVICE_TYPE=%d\n", peripheral_device_type); + } else { + if (serial[0] != '\0') + printf("%s_%s\n", model, serial); +-- +2.33.0 + diff --git a/systemd.spec b/systemd.spec index d884476..d16b460 100644 --- a/systemd.spec +++ b/systemd.spec @@ -21,7 +21,7 @@ Name: systemd Url: https://www.freedesktop.org/wiki/Software/systemd Version: 249 -Release: 66 +Release: 67 License: MIT and LGPLv2+ and GPLv2+ Summary: System and Service Manager @@ -613,13 +613,25 @@ Patch6564: backport-rules-import-previous-SYSTEMD_READY-state-for-suspen.pa Patch6565: backport-rules-go-to-the-end-of-rules-indeed-when-dm-is-suspe.patch Patch6566: backport-CVE-2023-7008.patch Patch6567: backport-core-add-possibility-to-not-track-certain-unit-types.patch -Patch6568: backport-sd-device-reduce-indentation.patch -Patch6569: backport-sd-device-use-ERRNO_IS_DEVICE_ABSENT-at-one-more-pla.patch -Patch6570: backport-sd-device-fix-possible-use-of-uninitialized-value.patch -Patch6571: backport-sd-device-rename-arguments-and-variables.patch -Patch6572: backport-sd-device-drop-unused-device_copy_properties.patch -Patch6573: backport-sd-device-make-device_shallow_clone-static.patch -Patch6574: backport-sd-device-do-not-read-uevent-file-in-device_clone_wi.patch +Patch6568: backport-journal-recalculate-line_max-when-stdout-stream-stat.patch +Patch6569: backport-pid1-terminate-cylon-string.patch +Patch6570: backport-pid1-move-draw_cylong-to-pretty-print.-ch.patch +Patch6571: backport-test-add-test-for-draw_cylon.patch +Patch6572: backport-locale-util-do-not-call-setlocale-when-multi-threade.patch +Patch6573: backport-resolve-fix-wrong-error-cause-assignment-to-log_debu.patch +Patch6574: backport-resolve-do-not-trigger-assertion-on-exit.patch +Patch6575: backport-network-neighbor-add-missing-OOM-check.patch +Patch6576: backport-dissect-tool-right-align-the-partition-number.patch +Patch6577: backport-dissect-image-fix-fd-leak-in-dissected_image_acquire.patch +Patch6578: backport-udev-even-if-a-device-is-a-zac-device-scsi-ID_SERIAL.patch +Patch6579: backport-core-log-message-when-reloading-finishes.patch +Patch6580: backport-sd-device-reduce-indentation.patch +Patch6581: backport-sd-device-use-ERRNO_IS_DEVICE_ABSENT-at-one-more-pla.patch +Patch6582: backport-sd-device-fix-possible-use-of-uninitialized-value.patch +Patch6583: backport-sd-device-rename-arguments-and-variables.patch +Patch6584: backport-sd-device-drop-unused-device_copy_properties.patch +Patch6585: backport-sd-device-make-device_shallow_clone-static.patch +Patch6586: backport-sd-device-do-not-read-uevent-file-in-device_clone_wi.patch Patch9001: update-rtc-with-system-clock-when-shutdown.patch Patch9002: udev-add-actions-while-rename-netif-failed.patch @@ -2119,6 +2131,21 @@ grep -q -E '^KEYMAP="?fi-latin[19]"?' /etc/vconsole.conf 2>/dev/null && %{_libdir}/security/pam_systemd.so %changelog +* Thu Feb 22 2024 wangyuhang - 249-67 +- backport: sync patches from systemd community + add backport-journal-recalculate-line_max-when-stdout-stream-stat.patch + backport-pid1-terminate-cylon-string.patch + backport-pid1-move-draw_cylong-to-pretty-print.-ch.patch + backport-test-add-test-for-draw_cylon.patch + backport-locale-util-do-not-call-setlocale-when-multi-threade.patch + backport-resolve-fix-wrong-error-cause-assignment-to-log_debu.patch + backport-resolve-do-not-trigger-assertion-on-exit.patch + backport-network-neighbor-add-missing-OOM-check.patch + backport-dissect-tool-right-align-the-partition-number.patch + backport-dissect-image-fix-fd-leak-in-dissected_image_acquire.patch + backport-udev-even-if-a-device-is-a-zac-device-scsi-ID_SERIAL.patch + backport-core-log-message-when-reloading-finishes.patch + * Wed Feb 21 2024 huyubiao - 249-66 - fix the old symbolic links are not deleted when the NVMe partition is renamed