From eb8b6e3f770e4f39e112b5f69fcf88757f09ab8f Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Mar 15 2022 09:14:57 +0000 Subject: import systemd-239-51.el8_5.5 --- diff --git a/SOURCES/0666-Do-not-fail-if-the-same-alt.-name-is-set-again.patch b/SOURCES/0666-Do-not-fail-if-the-same-alt.-name-is-set-again.patch new file mode 100644 index 0000000..ffafa82 --- /dev/null +++ b/SOURCES/0666-Do-not-fail-if-the-same-alt.-name-is-set-again.patch @@ -0,0 +1,27 @@ +From 21c071fbd05d112ccd92b7a49e53bf8d38cdbd06 Mon Sep 17 00:00:00 2001 +From: David Tardon +Date: Wed, 8 Dec 2021 09:49:24 +0100 +Subject: [PATCH] Do not fail if the same alt. name is set again + +This is a workaround for a kernel bug. + +RHEL-only + +Resolves: #2030027 +--- + src/udev/net/link-config.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c +index 5220f247f0..9046c5bd2a 100644 +--- a/src/udev/net/link-config.c ++++ b/src/udev/net/link-config.c +@@ -526,7 +526,7 @@ int link_config_apply(link_config_ctx *ctx, link_config *config, + strv_uniq(altnames); + strv_sort(altnames); + r = rtnl_set_link_alternative_names(&ctx->rtnl, ifindex, altnames); +- if (r == -EOPNOTSUPP) ++ if (IN_SET(r, -EOPNOTSUPP, -EEXIST)) + log_debug_errno(r, "Could not set AlternativeName= or apply AlternativeNamesPolicy= on %s, ignoring: %m", old_name); + else if (r < 0) + return log_warning_errno(r, "Could not set AlternativeName= or apply AlternativeNamesPolicy= on %s: %m", old_name); diff --git a/SOURCES/0667-meson-avoid-bogus-meson-warning.patch b/SOURCES/0667-meson-avoid-bogus-meson-warning.patch new file mode 100644 index 0000000..4bdfec5 --- /dev/null +++ b/SOURCES/0667-meson-avoid-bogus-meson-warning.patch @@ -0,0 +1,38 @@ +From 0e03f2192cd80e6a4a1bf83f0238cc6d133b8475 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Thu, 7 Nov 2019 11:32:26 +0100 +Subject: [PATCH] meson: avoid bogus meson warning + +With meson-0.52.0-1.module_f31+6771+f5d842eb.noarch I get: +src/test/meson.build:19: WARNING: Overriding previous value of environment variable 'PATH' with a new one + +When we're using *prepend*, the whole point is to modify an existing variable, +so meson shouldn't warn. But let's set avoid the warning and shorten things by +setting the final value immediately. + +(cherry picked from commit cbe804947482998cc767bfb0c169e6263a6ef097) + +Related: #2030027 +--- + src/test/meson.build | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/src/test/meson.build b/src/test/meson.build +index 7b310d4ec7..4bbc67d367 100644 +--- a/src/test/meson.build ++++ b/src/test/meson.build +@@ -10,12 +10,11 @@ test_hashmap_ordered_c = custom_target( + + test_include_dir = include_directories('.') + +-path = run_command('sh', ['-c', 'echo "$PATH"']).stdout() ++path = run_command('sh', ['-c', 'echo "$PATH"']).stdout().strip() + test_env = environment() + test_env.set('SYSTEMD_KBD_MODEL_MAP', kbd_model_map) + test_env.set('SYSTEMD_LANGUAGE_FALLBACK_MAP', language_fallback_map) +-test_env.set('PATH', path) +-test_env.prepend('PATH', meson.build_root()) ++test_env.set('PATH', '@0@:@1@'.format(meson.build_root(), path)) + + ############################################################ + diff --git a/SOURCES/0668-meson-do-not-fail-if-rsync-is-not-installed-with-mes.patch b/SOURCES/0668-meson-do-not-fail-if-rsync-is-not-installed-with-mes.patch new file mode 100644 index 0000000..9dc08d1 --- /dev/null +++ b/SOURCES/0668-meson-do-not-fail-if-rsync-is-not-installed-with-mes.patch @@ -0,0 +1,54 @@ +From 112de8e094470d2a8df4f7c9b8ca62bd68c96a70 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Mon, 12 Apr 2021 14:03:32 +0200 +Subject: [PATCH] meson: do not fail if rsync is not installed with meson + 0.57.2 + +https://github.com/mesonbuild/meson/issues/8641 + +Our CI started to fail. Even if the change is reverted in meson, +we need a quick workaround here. + +(cherry picked from commit 7c5fd25119a495009ea62f79e5daec34cc464628) + +Related: #2030027 +--- + man/meson.build | 25 ++++++++++++++----------- + 1 file changed, 14 insertions(+), 11 deletions(-) + +diff --git a/man/meson.build b/man/meson.build +index a953d34098..efc8836d0c 100644 +--- a/man/meson.build ++++ b/man/meson.build +@@ -178,17 +178,20 @@ html = custom_target( + depends : html_pages, + command : ['echo']) + +-run_target( +- 'doc-sync', +- depends : man_pages + html_pages, +- command : ['rsync', '-rlv', +- '--delete-excluded', +- '--include=man', +- '--include=*.html', +- '--exclude=*', +- '--omit-dir-times', +- meson.current_build_dir(), +- get_option('www-target')]) ++rsync = find_program('rsync', required : false) ++if rsync.found() ++ run_target( ++ 'doc-sync', ++ depends : man_pages + html_pages, ++ command : [rsync, '-rlv', ++ '--delete-excluded', ++ '--include=man', ++ '--include=*.html', ++ '--exclude=*', ++ '--omit-dir-times', ++ meson.current_build_dir(), ++ get_option('www-target')]) ++endif + + ############################################################ + diff --git a/SOURCES/0669-mount-don-t-propagate-errors-from-mount_setup_unit-f.patch b/SOURCES/0669-mount-don-t-propagate-errors-from-mount_setup_unit-f.patch new file mode 100644 index 0000000..670c443 --- /dev/null +++ b/SOURCES/0669-mount-don-t-propagate-errors-from-mount_setup_unit-f.patch @@ -0,0 +1,51 @@ +From 4662575605089b38d611a911c03c60ec260fde05 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 28 Nov 2018 12:41:44 +0100 +Subject: [PATCH] mount: don't propagate errors from mount_setup_unit() further + up + +If we can't process a specific line in /proc/self/mountinfo we should +log about it (which we do), but this should not affect other lines, nor +further processing of mount units. Let's keep these failures local. + +Fixes: #10874 + +(cherry picked from commit ba0d56f55f2073164799be714b5bd1aad94d059a) + +Resolves: #2039327 +--- + src/core/mount.c | 8 ++------ + 1 file changed, 2 insertions(+), 6 deletions(-) + +diff --git a/src/core/mount.c b/src/core/mount.c +index 7e80a0c974..9b1c59b1c3 100644 +--- a/src/core/mount.c ++++ b/src/core/mount.c +@@ -1621,12 +1621,10 @@ static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) { + if (r < 0) + return log_error_errno(r, "Failed to parse /proc/self/mountinfo: %m"); + +- r = 0; + for (;;) { + struct libmnt_fs *fs; + const char *device, *path, *options, *fstype; + _cleanup_free_ char *d = NULL, *p = NULL; +- int k; + + r = mnt_table_next_fs(table, iter, &fs); + if (r == 1) +@@ -1650,12 +1648,10 @@ static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) { + + device_found_node(m, d, DEVICE_FOUND_MOUNT, DEVICE_FOUND_MOUNT); + +- k = mount_setup_unit(m, d, p, options, fstype, set_flags); +- if (r == 0 && k < 0) +- r = k; ++ (void) mount_setup_unit(m, d, p, options, fstype, set_flags); + } + +- return r; ++ return 0; + } + + static void mount_shutdown(Manager *m) { diff --git a/SOURCES/0670-test-make-TEST-47-less-racy.patch b/SOURCES/0670-test-make-TEST-47-less-racy.patch new file mode 100644 index 0000000..e5c9f88 --- /dev/null +++ b/SOURCES/0670-test-make-TEST-47-less-racy.patch @@ -0,0 +1,35 @@ +From a423abe6a3914364c36d4299c1b770fdbe376834 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Wed, 15 Dec 2021 12:15:19 +0100 +Subject: [PATCH] test: make TEST-47 less racy + +Based on: + - 2e7090e94d0c8b31d418555ab2f6a9b75318f6a4 + - e00e2e0b50bbd120290572c8d1242703fb98b34e + - 197298ff9fc930de450330095cc5b67d165d0801 + +Related: #2039327 + +(cherry picked from commit de7125dcfe6d6c8af05262ab786f9fe7cbf15113) +--- + test/TEST-47-ISSUE-14566/testsuite.sh | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/test/TEST-47-ISSUE-14566/testsuite.sh b/test/TEST-47-ISSUE-14566/testsuite.sh +index d917cf52ff..b12b50e96c 100755 +--- a/test/TEST-47-ISSUE-14566/testsuite.sh ++++ b/test/TEST-47-ISSUE-14566/testsuite.sh +@@ -6,11 +6,13 @@ systemd-analyze log-level debug + systemd-analyze log-target console + + systemctl start issue_14566_test ++sleep 4 + systemctl status issue_14566_test + + leaked_pid=$(cat /leakedtestpid) + + systemctl stop issue_14566_test ++sleep 4 + + # Leaked PID will still be around if we're buggy. + # I personally prefer to see 42. diff --git a/SOURCES/0671-macro-define-HAS_FEATURE_ADDRESS_SANITIZER-also-on-g.patch b/SOURCES/0671-macro-define-HAS_FEATURE_ADDRESS_SANITIZER-also-on-g.patch new file mode 100644 index 0000000..ed2f3d5 --- /dev/null +++ b/SOURCES/0671-macro-define-HAS_FEATURE_ADDRESS_SANITIZER-also-on-g.patch @@ -0,0 +1,38 @@ +From c132731b260174f5939099ceb4fccde84710c502 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 3 Dec 2018 17:30:19 +0100 +Subject: [PATCH] macro: define HAS_FEATURE_ADDRESS_SANITIZER also on gcc + +Let's make differences between compilers more minimal. + +Related: #2039327 + +(cherry picked from commit 01da36fadd365329cfd9e2c97eb419c63404b25f) +--- + src/basic/macro.h | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/src/basic/macro.h b/src/basic/macro.h +index 0fe6a62aa8..e87026882f 100644 +--- a/src/basic/macro.h ++++ b/src/basic/macro.h +@@ -55,6 +55,19 @@ + # endif + #endif + ++#if !defined(HAS_FEATURE_ADDRESS_SANITIZER) ++# ifdef __SANITIZE_ADDRESS__ ++# define HAS_FEATURE_ADDRESS_SANITIZER 1 ++# elif defined(__has_feature) ++# if __has_feature(address_sanitizer) ++# define HAS_FEATURE_ADDRESS_SANITIZER 1 ++# endif ++# endif ++# if !defined(HAS_FEATURE_ADDRESS_SANITIZER) ++# define HAS_FEATURE_ADDRESS_SANITIZER 0 ++# endif ++#endif ++ + /* Temporarily disable some warnings */ + #define DISABLE_WARNING_DECLARATION_AFTER_STATEMENT \ + _Pragma("GCC diagnostic push"); \ diff --git a/SOURCES/0672-tests-add-helper-function-to-autodetect-CI-environme.patch b/SOURCES/0672-tests-add-helper-function-to-autodetect-CI-environme.patch new file mode 100644 index 0000000..01d8709 --- /dev/null +++ b/SOURCES/0672-tests-add-helper-function-to-autodetect-CI-environme.patch @@ -0,0 +1,104 @@ +From ccdf0a116dcba01ec4d8caec0baef2910d8d9800 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Mon, 29 Nov 2021 13:00:21 +0100 +Subject: [PATCH] tests: add helper function to autodetect CI environments + +Sadly there is no standarized way to check if we're running in some +CI environment. So let's try to gather the heuristics in one helper +function. + +(cherry picked from commit 6fbbf368f5a6d181b21f448255d5a4182dc2ab3a) + +Related: #2039327 +--- + src/basic/string-util.h | 6 ++++++ + src/shared/tests.c | 42 +++++++++++++++++++++++++++++++++++++++++ + src/shared/tests.h | 3 +++ + 3 files changed, 51 insertions(+) + +diff --git a/src/basic/string-util.h b/src/basic/string-util.h +index 96a9260f93..742b566932 100644 +--- a/src/basic/string-util.h ++++ b/src/basic/string-util.h +@@ -32,6 +32,12 @@ static inline bool streq_ptr(const char *a, const char *b) { + return strcmp_ptr(a, b) == 0; + } + ++static inline char* strstr_ptr(const char *haystack, const char *needle) { ++ if (!haystack || !needle) ++ return NULL; ++ return strstr(haystack, needle); ++} ++ + static inline const char* strempty(const char *s) { + return s ?: ""; + } +diff --git a/src/shared/tests.c b/src/shared/tests.c +index 100b62b9b0..1da80d653f 100644 +--- a/src/shared/tests.c ++++ b/src/shared/tests.c +@@ -7,7 +7,9 @@ + #include + + #include "tests.h" ++#include "env-util.h" + #include "path-util.h" ++#include "strv.h" + + char* setup_fake_runtime_dir(void) { + char t[] = "/tmp/fake-xdg-runtime-XXXXXX", *p; +@@ -75,3 +77,43 @@ void test_setup_logging(int level) { + log_parse_environment(); + log_open(); + } ++ ++const char *ci_environment(void) { ++ /* We return a string because we might want to provide multiple bits of information later on: not ++ * just the general CI environment type, but also whether we're sanitizing or not, etc. The caller is ++ * expected to use strstr on the returned value. */ ++ static const char *ans = (void*) UINTPTR_MAX; ++ const char *p; ++ int r; ++ ++ if (ans != (void*) UINTPTR_MAX) ++ return ans; ++ ++ /* We allow specifying the environment with $CITYPE. Nobody uses this so far, but we are ready. */ ++ p = getenv("CITYPE"); ++ if (!isempty(p)) ++ return (ans = p); ++ ++ if (getenv_bool("TRAVIS") > 0) ++ return (ans = "travis"); ++ if (getenv_bool("SEMAPHORE") > 0) ++ return (ans = "semaphore"); ++ if (getenv_bool("GITHUB_ACTIONS") > 0) ++ return (ans = "github-actions"); ++ if (getenv("AUTOPKGTEST_ARTIFACTS") || getenv("AUTOPKGTEST_TMP")) ++ return (ans = "autopkgtest"); ++ ++ FOREACH_STRING(p, "CI", "CONTINOUS_INTEGRATION") { ++ /* Those vars are booleans according to Semaphore and Travis docs: ++ * https://docs.travis-ci.com/user/environment-variables/#default-environment-variables ++ * https://docs.semaphoreci.com/ci-cd-environment/environment-variables/#ci ++ */ ++ r = getenv_bool(p); ++ if (r > 0) ++ return (ans = "unknown"); /* Some other unknown thing */ ++ if (r == 0) ++ return (ans = NULL); ++ } ++ ++ return (ans = NULL); ++} +diff --git a/src/shared/tests.h b/src/shared/tests.h +index 3d696d02fd..4f8f349097 100644 +--- a/src/shared/tests.h ++++ b/src/shared/tests.h +@@ -5,3 +5,6 @@ char* setup_fake_runtime_dir(void); + bool test_is_running_from_builddir(char **exedir); + const char* get_testdata_dir(void); + void test_setup_logging(int level); ++ ++/* Provide a convenient way to check if we're running in CI. */ ++const char *ci_environment(void); diff --git a/SOURCES/0673-strv-rework-FOREACH_STRING-macro.patch b/SOURCES/0673-strv-rework-FOREACH_STRING-macro.patch new file mode 100644 index 0000000..ca14931 --- /dev/null +++ b/SOURCES/0673-strv-rework-FOREACH_STRING-macro.patch @@ -0,0 +1,50 @@ +From ad8b47946941e6a1f3ae778f5e8563ddf532b2ba Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 16 Jan 2019 00:13:38 +0100 +Subject: [PATCH] strv: rework FOREACH_STRING() macro + +So it's apparently problematic that we use STRV_MAKE() (i.e. a compound +initializer) outside of the {} block we use it in (and that includes +outside of the ({}) block, too). Hence, let's rework the macro to not +need that. + +This also makes the macro shorter, which is definitely a good and more +readable. Moreover, it will now complain if the iterator is a "char*" +instead of a "const char*", which is good too. + +Fixes: #11394 +(cherry picked from commit 66a64081f82dfad90f2f9394a477820a2e3e6510) + +(cherry picked from commit 3539a72c260063713e4ecba17966ba9a768d8af9) + +Related: #2039327 +--- + src/basic/strv.h | 15 ++++----------- + 1 file changed, 4 insertions(+), 11 deletions(-) + +diff --git a/src/basic/strv.h b/src/basic/strv.h +index c1e4c973b6..a09d76706d 100644 +--- a/src/basic/strv.h ++++ b/src/basic/strv.h +@@ -148,17 +148,10 @@ void strv_print(char **l); + _found; \ + }) + +-#define FOREACH_STRING(x, ...) \ +- for (char **_l = ({ \ +- char **_ll = STRV_MAKE(__VA_ARGS__); \ +- x = _ll ? _ll[0] : NULL; \ +- _ll; \ +- }); \ +- _l && *_l; \ +- x = ({ \ +- _l ++; \ +- _l[0]; \ +- })) ++#define FOREACH_STRING(x, y, ...) \ ++ for (char **_l = STRV_MAKE(({ x = y; }), ##__VA_ARGS__); \ ++ x; \ ++ x = *(++_l)) + + char **strv_reverse(char **l); + char **strv_shell_escape(char **l, const char *bad); diff --git a/SOURCES/0674-test-systemctl-use-const-char-instead-of-char.patch b/SOURCES/0674-test-systemctl-use-const-char-instead-of-char.patch new file mode 100644 index 0000000..da4898d --- /dev/null +++ b/SOURCES/0674-test-systemctl-use-const-char-instead-of-char.patch @@ -0,0 +1,47 @@ +From 5a45664f9b5d2ba7550ed1c12550554688b70f5c Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Mon, 29 Nov 2021 13:47:24 +0100 +Subject: [PATCH] test,systemctl: use "const char*" instead of "char*" + +as iterator for FOREACH_STRING() + +The macro iterates through literal strings (i.e. constant strings), +hence it's more correct to have the iterator const too. + +Based on b2238e380e5f2fbcc129643b3fbd66f2828fd57c. + +(cherry picked from commit fdfff847313222eed3306ac605db46d8cbd23212) + +Related: #2039327 +--- + src/systemctl/systemctl.c | 3 ++- + src/test/test-execute.c | 2 +- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c +index 3dd7c1522f..b967550b97 100644 +--- a/src/systemctl/systemctl.c ++++ b/src/systemctl/systemctl.c +@@ -7011,7 +7011,8 @@ static int run_editor(char **paths) { + if (r == 0) { + const char **args; + char *editor, **editor_args = NULL; +- char **tmp_path, **original_path, *p; ++ char **tmp_path, **original_path; ++ const char *p; + size_t n_editor_args = 0, i = 1; + size_t argc; + +diff --git a/src/test/test-execute.c b/src/test/test-execute.c +index 294f8fe7dd..4d21301982 100644 +--- a/src/test/test-execute.c ++++ b/src/test/test-execute.c +@@ -146,7 +146,7 @@ invalid: + } + + static bool is_inaccessible_available(void) { +- char *p; ++ const char *p; + + FOREACH_STRING(p, + "/run/systemd/inaccessible/reg", diff --git a/SOURCES/0675-ci-pass-the-GITHUB_ACTIONS-variable-to-the-CentOS-co.patch b/SOURCES/0675-ci-pass-the-GITHUB_ACTIONS-variable-to-the-CentOS-co.patch new file mode 100644 index 0000000..6d1f06d --- /dev/null +++ b/SOURCES/0675-ci-pass-the-GITHUB_ACTIONS-variable-to-the-CentOS-co.patch @@ -0,0 +1,29 @@ +From d9542b919237306baee2d2396794f63da67b1314 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Mon, 29 Nov 2021 13:59:41 +0100 +Subject: [PATCH] ci: pass the $GITHUB_ACTIONS variable to the CentOS container + +so we can properly skip tests which are problematic when running in GH +Actions. + +Related: #2039327 +rhel-only + +(cherry picked from commit a8fd8d157c832ddad34a9a3e372579c58261f7fb) +--- + .github/workflows/unit_tests.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/.github/workflows/unit_tests.sh b/.github/workflows/unit_tests.sh +index 814870e7a0..c1311310fb 100755 +--- a/.github/workflows/unit_tests.sh ++++ b/.github/workflows/unit_tests.sh +@@ -131,7 +131,7 @@ for phase in "${PHASES[@]}"; do + # Pull a Docker image and start a new container + docker pull quay.io/centos/centos:$CENTOS_RELEASE + info "Starting container $CONT_NAME" +- $DOCKER_RUN -v $REPO_ROOT:/build:rw \ ++ $DOCKER_RUN -v $REPO_ROOT:/build:rw -e GITHUB_ACTIONS="$GITHUB_ACTIONS" \ + -w /build --privileged=true --name $CONT_NAME \ + -dit --net=host quay.io/centos/centos:$CENTOS_RELEASE /sbin/init + diff --git a/SOURCES/0676-core-rename-unit_-start_limit-condition-assert-_test.patch b/SOURCES/0676-core-rename-unit_-start_limit-condition-assert-_test.patch new file mode 100644 index 0000000..0913a49 --- /dev/null +++ b/SOURCES/0676-core-rename-unit_-start_limit-condition-assert-_test.patch @@ -0,0 +1,179 @@ +From f1f0eb4d262e91830324de3f99fa58cd154a7876 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 18 Mar 2019 12:21:27 +0100 +Subject: [PATCH] core: rename unit_{start_limit|condition|assert}_test() to + unit_test_xyz() + +Just some renaming, no change in behaviour. + +Background: I'd like to add more functions unit_test_xyz() that test +various things, hence let's streamline the naming a bit. + +(cherry picked from commit 97a3f4ee052e1b8a0ff03accfa478e352891a84f) + +Related: #2037395 +--- + src/core/automount.c | 2 +- + src/core/mount.c | 2 +- + src/core/path.c | 2 +- + src/core/service.c | 2 +- + src/core/socket.c | 2 +- + src/core/swap.c | 2 +- + src/core/timer.c | 2 +- + src/core/unit.c | 11 +++++------ + src/core/unit.h | 2 +- + 9 files changed, 13 insertions(+), 14 deletions(-) + +diff --git a/src/core/automount.c b/src/core/automount.c +index 76e70f4dac..2bc160cb07 100644 +--- a/src/core/automount.c ++++ b/src/core/automount.c +@@ -808,7 +808,7 @@ static int automount_start(Unit *u) { + return -ENOENT; + } + +- r = unit_start_limit_test(u); ++ r = unit_test_start_limit(u); + if (r < 0) { + automount_enter_dead(a, AUTOMOUNT_FAILURE_START_LIMIT_HIT); + return r; +diff --git a/src/core/mount.c b/src/core/mount.c +index 9b1c59b1c3..4cb49d845d 100644 +--- a/src/core/mount.c ++++ b/src/core/mount.c +@@ -1065,7 +1065,7 @@ static int mount_start(Unit *u) { + + assert(IN_SET(m->state, MOUNT_DEAD, MOUNT_FAILED)); + +- r = unit_start_limit_test(u); ++ r = unit_test_start_limit(u); + if (r < 0) { + mount_enter_dead(m, MOUNT_FAILURE_START_LIMIT_HIT); + return r; +diff --git a/src/core/path.c b/src/core/path.c +index ed40bc6c19..4bccc0396b 100644 +--- a/src/core/path.c ++++ b/src/core/path.c +@@ -565,7 +565,7 @@ static int path_start(Unit *u) { + return -ENOENT; + } + +- r = unit_start_limit_test(u); ++ r = unit_test_start_limit(u); + if (r < 0) { + path_enter_dead(p, PATH_FAILURE_START_LIMIT_HIT); + return r; +diff --git a/src/core/service.c b/src/core/service.c +index 5e3e75b5ae..01cb1a375e 100644 +--- a/src/core/service.c ++++ b/src/core/service.c +@@ -2357,7 +2357,7 @@ static int service_start(Unit *u) { + assert(IN_SET(s->state, SERVICE_DEAD, SERVICE_FAILED)); + + /* Make sure we don't enter a busy loop of some kind. */ +- r = unit_start_limit_test(u); ++ r = unit_test_start_limit(u); + if (r < 0) { + service_enter_dead(s, SERVICE_FAILURE_START_LIMIT_HIT, false); + return r; +diff --git a/src/core/socket.c b/src/core/socket.c +index 50c32ed8f4..09491c6677 100644 +--- a/src/core/socket.c ++++ b/src/core/socket.c +@@ -2469,7 +2469,7 @@ static int socket_start(Unit *u) { + + assert(IN_SET(s->state, SOCKET_DEAD, SOCKET_FAILED)); + +- r = unit_start_limit_test(u); ++ r = unit_test_start_limit(u); + if (r < 0) { + socket_enter_dead(s, SOCKET_FAILURE_START_LIMIT_HIT); + return r; +diff --git a/src/core/swap.c b/src/core/swap.c +index a8f127f660..823699699e 100644 +--- a/src/core/swap.c ++++ b/src/core/swap.c +@@ -851,7 +851,7 @@ static int swap_start(Unit *u) { + if (UNIT(other)->job && UNIT(other)->job->state == JOB_RUNNING) + return -EAGAIN; + +- r = unit_start_limit_test(u); ++ r = unit_test_start_limit(u); + if (r < 0) { + swap_enter_dead(s, SWAP_FAILURE_START_LIMIT_HIT); + return r; +diff --git a/src/core/timer.c b/src/core/timer.c +index 1718ffc5a5..be16321296 100644 +--- a/src/core/timer.c ++++ b/src/core/timer.c +@@ -599,7 +599,7 @@ static int timer_start(Unit *u) { + return -ENOENT; + } + +- r = unit_start_limit_test(u); ++ r = unit_test_start_limit(u); + if (r < 0) { + timer_enter_dead(t, TIMER_FAILURE_START_LIMIT_HIT); + return r; +diff --git a/src/core/unit.c b/src/core/unit.c +index 152a860d08..fa94a67fdd 100644 +--- a/src/core/unit.c ++++ b/src/core/unit.c +@@ -1633,7 +1633,7 @@ static bool unit_condition_test_list(Unit *u, Condition *first, const char *(*to + return triggered != 0; + } + +-static bool unit_condition_test(Unit *u) { ++static bool unit_test_condition(Unit *u) { + assert(u); + + dual_timestamp_get(&u->condition_timestamp); +@@ -1642,7 +1642,7 @@ static bool unit_condition_test(Unit *u) { + return u->condition_result; + } + +-static bool unit_assert_test(Unit *u) { ++static bool unit_test_assert(Unit *u) { + assert(u); + + dual_timestamp_get(&u->assert_timestamp); +@@ -1657,8 +1657,7 @@ void unit_status_printf(Unit *u, const char *status, const char *unit_status_msg + REENABLE_WARNING; + } + +- +-int unit_start_limit_test(Unit *u) { ++int unit_test_start_limit(Unit *u) { + assert(u); + + if (ratelimit_below(&u->start_limit)) { +@@ -1748,14 +1747,14 @@ int unit_start(Unit *u) { + * speed up activation in case there is some hold-off time, + * but we don't want to recheck the condition in that case. */ + if (state != UNIT_ACTIVATING && +- !unit_condition_test(u)) { ++ !unit_test_condition(u)) { + log_unit_debug(u, "Starting requested but condition failed. Not starting unit."); + return -EALREADY; + } + + /* If the asserts failed, fail the entire job */ + if (state != UNIT_ACTIVATING && +- !unit_assert_test(u)) { ++ !unit_test_assert(u)) { + log_unit_notice(u, "Starting requested but asserts failed."); + return -EPROTO; + } +diff --git a/src/core/unit.h b/src/core/unit.h +index ec45b5fb48..a8bc350b66 100644 +--- a/src/core/unit.h ++++ b/src/core/unit.h +@@ -786,7 +786,7 @@ static inline bool unit_supported(Unit *u) { + void unit_warn_if_dir_nonempty(Unit *u, const char* where); + int unit_fail_if_noncanonical(Unit *u, const char* where); + +-int unit_start_limit_test(Unit *u); ++int unit_test_start_limit(Unit *u); + + void unit_unref_uid(Unit *u, bool destroy_now); + int unit_ref_uid(Unit *u, uid_t uid, bool clean_ipc); diff --git a/SOURCES/0677-core-Check-unit-start-rate-limiting-earlier.patch b/SOURCES/0677-core-Check-unit-start-rate-limiting-earlier.patch new file mode 100644 index 0000000..0f792d0 --- /dev/null +++ b/SOURCES/0677-core-Check-unit-start-rate-limiting-earlier.patch @@ -0,0 +1,400 @@ +From 6f3b6308bb5705fdcadec3f4cac105211bc0a3e2 Mon Sep 17 00:00:00 2001 +From: Daan De Meyer +Date: Tue, 24 Aug 2021 16:46:47 +0100 +Subject: [PATCH] core: Check unit start rate limiting earlier + +Fixes #17433. Currently, if any of the validations we do before we +check start rate limiting fail, we can still enter a busy loop as +no rate limiting gets applied. A common occurence of this scenario +is path units triggering a service that fails a condition check. + +To fix the issue, we simply move up start rate limiting checks to +be the first thing we do when starting a unit. To achieve this, +we add a new method to the unit vtable and implement it for the +relevant unit types so that we can do the start rate limit checks +earlier on. + +(cherry picked from commit 9727f2427ff6b2e1f4ab927cc57ad8e888f04e95) + +Related: #2037395 + +[msekleta: I've deleted part of the original commit that adds test for +issue #17433. This was necessary because upstream commit assumes newer +organization of the test code which we don't have in RHEL-8 tree. As +a consequence we must add explicit test for this in the internal +test-suite.] +--- + src/core/automount.c | 23 +++++++++++++++++------ + src/core/mount.c | 23 +++++++++++++++++------ + src/core/path.c | 23 +++++++++++++++++------ + src/core/service.c | 25 ++++++++++++++++++------- + src/core/socket.c | 23 +++++++++++++++++------ + src/core/swap.c | 23 +++++++++++++++++------ + src/core/timer.c | 22 ++++++++++++++++------ + src/core/unit.c | 14 ++++++++++---- + src/core/unit.h | 4 ++++ + 9 files changed, 133 insertions(+), 47 deletions(-) + +diff --git a/src/core/automount.c b/src/core/automount.c +index 2bc160cb07..5e16adabb5 100644 +--- a/src/core/automount.c ++++ b/src/core/automount.c +@@ -808,12 +808,6 @@ static int automount_start(Unit *u) { + return -ENOENT; + } + +- r = unit_test_start_limit(u); +- if (r < 0) { +- automount_enter_dead(a, AUTOMOUNT_FAILURE_START_LIMIT_HIT); +- return r; +- } +- + r = unit_acquire_invocation_id(u); + if (r < 0) + return r; +@@ -1077,6 +1071,21 @@ static bool automount_supported(void) { + return supported; + } + ++static int automount_test_start_limit(Unit *u) { ++ Automount *a = AUTOMOUNT(u); ++ int r; ++ ++ assert(a); ++ ++ r = unit_test_start_limit(u); ++ if (r < 0) { ++ automount_enter_dead(a, AUTOMOUNT_FAILURE_START_LIMIT_HIT); ++ return r; ++ } ++ ++ return 0; ++} ++ + static const char* const automount_result_table[_AUTOMOUNT_RESULT_MAX] = { + [AUTOMOUNT_SUCCESS] = "success", + [AUTOMOUNT_FAILURE_RESOURCES] = "resources", +@@ -1135,4 +1144,6 @@ const UnitVTable automount_vtable = { + [JOB_FAILED] = "Failed to unset automount %s.", + }, + }, ++ ++ .test_start_limit = automount_test_start_limit, + }; +diff --git a/src/core/mount.c b/src/core/mount.c +index 4cb49d845d..619f64d5b7 100644 +--- a/src/core/mount.c ++++ b/src/core/mount.c +@@ -1065,12 +1065,6 @@ static int mount_start(Unit *u) { + + assert(IN_SET(m->state, MOUNT_DEAD, MOUNT_FAILED)); + +- r = unit_test_start_limit(u); +- if (r < 0) { +- mount_enter_dead(m, MOUNT_FAILURE_START_LIMIT_HIT); +- return r; +- } +- + r = unit_acquire_invocation_id(u); + if (r < 0) + return r; +@@ -1953,6 +1947,21 @@ static int mount_control_pid(Unit *u) { + return m->control_pid; + } + ++static int mount_test_start_limit(Unit *u) { ++ Mount *m = MOUNT(u); ++ int r; ++ ++ assert(m); ++ ++ r = unit_test_start_limit(u); ++ if (r < 0) { ++ mount_enter_dead(m, MOUNT_FAILURE_START_LIMIT_HIT); ++ return r; ++ } ++ ++ return 0; ++} ++ + static const char* const mount_exec_command_table[_MOUNT_EXEC_COMMAND_MAX] = { + [MOUNT_EXEC_MOUNT] = "ExecMount", + [MOUNT_EXEC_UNMOUNT] = "ExecUnmount", +@@ -2044,4 +2053,6 @@ const UnitVTable mount_vtable = { + [JOB_TIMEOUT] = "Timed out unmounting %s.", + }, + }, ++ ++ .test_start_limit = mount_test_start_limit, + }; +diff --git a/src/core/path.c b/src/core/path.c +index 4bccc0396b..1e69a1f05f 100644 +--- a/src/core/path.c ++++ b/src/core/path.c +@@ -565,12 +565,6 @@ static int path_start(Unit *u) { + return -ENOENT; + } + +- r = unit_test_start_limit(u); +- if (r < 0) { +- path_enter_dead(p, PATH_FAILURE_START_LIMIT_HIT); +- return r; +- } +- + r = unit_acquire_invocation_id(u); + if (r < 0) + return r; +@@ -730,6 +724,21 @@ static void path_reset_failed(Unit *u) { + p->result = PATH_SUCCESS; + } + ++static int path_test_start_limit(Unit *u) { ++ Path *p = PATH(u); ++ int r; ++ ++ assert(p); ++ ++ r = unit_test_start_limit(u); ++ if (r < 0) { ++ path_enter_dead(p, PATH_FAILURE_START_LIMIT_HIT); ++ return r; ++ } ++ ++ return 0; ++} ++ + static const char* const path_type_table[_PATH_TYPE_MAX] = { + [PATH_EXISTS] = "PathExists", + [PATH_EXISTS_GLOB] = "PathExistsGlob", +@@ -782,4 +791,6 @@ const UnitVTable path_vtable = { + + .bus_vtable = bus_path_vtable, + .bus_set_property = bus_path_set_property, ++ ++ .test_start_limit = path_test_start_limit, + }; +diff --git a/src/core/service.c b/src/core/service.c +index 01cb1a375e..a21d98ab8f 100644 +--- a/src/core/service.c ++++ b/src/core/service.c +@@ -2356,13 +2356,6 @@ static int service_start(Unit *u) { + + assert(IN_SET(s->state, SERVICE_DEAD, SERVICE_FAILED)); + +- /* Make sure we don't enter a busy loop of some kind. */ +- r = unit_test_start_limit(u); +- if (r < 0) { +- service_enter_dead(s, SERVICE_FAILURE_START_LIMIT_HIT, false); +- return r; +- } +- + r = unit_acquire_invocation_id(u); + if (r < 0) + return r; +@@ -4050,6 +4043,22 @@ static bool service_needs_console(Unit *u) { + SERVICE_FINAL_SIGKILL); + } + ++static int service_test_start_limit(Unit *u) { ++ Service *s = SERVICE(u); ++ int r; ++ ++ assert(s); ++ ++ /* Make sure we don't enter a busy loop of some kind. */ ++ r = unit_test_start_limit(u); ++ if (r < 0) { ++ service_enter_dead(s, SERVICE_FAILURE_START_LIMIT_HIT, false); ++ return r; ++ } ++ ++ return 0; ++} ++ + static const char* const service_restart_table[_SERVICE_RESTART_MAX] = { + [SERVICE_RESTART_NO] = "no", + [SERVICE_RESTART_ON_SUCCESS] = "on-success", +@@ -4191,4 +4200,6 @@ const UnitVTable service_vtable = { + [JOB_FAILED] = "Stopped (with error) %s.", + }, + }, ++ ++ .test_start_limit = service_test_start_limit, + }; +diff --git a/src/core/socket.c b/src/core/socket.c +index 09491c6677..36d2e4f823 100644 +--- a/src/core/socket.c ++++ b/src/core/socket.c +@@ -2469,12 +2469,6 @@ static int socket_start(Unit *u) { + + assert(IN_SET(s->state, SOCKET_DEAD, SOCKET_FAILED)); + +- r = unit_test_start_limit(u); +- if (r < 0) { +- socket_enter_dead(s, SOCKET_FAILURE_START_LIMIT_HIT); +- return r; +- } +- + r = unit_acquire_invocation_id(u); + if (r < 0) + return r; +@@ -3267,6 +3261,21 @@ static int socket_control_pid(Unit *u) { + return s->control_pid; + } + ++static int socket_test_start_limit(Unit *u) { ++ Socket *s = SOCKET(u); ++ int r; ++ ++ assert(s); ++ ++ r = unit_test_start_limit(u); ++ if (r < 0) { ++ socket_enter_dead(s, SOCKET_FAILURE_START_LIMIT_HIT); ++ return r; ++ } ++ ++ return 0; ++} ++ + static const char* const socket_exec_command_table[_SOCKET_EXEC_COMMAND_MAX] = { + [SOCKET_EXEC_START_PRE] = "ExecStartPre", + [SOCKET_EXEC_START_CHOWN] = "ExecStartChown", +@@ -3359,4 +3368,6 @@ const UnitVTable socket_vtable = { + [JOB_TIMEOUT] = "Timed out stopping %s.", + }, + }, ++ ++ .test_start_limit = socket_test_start_limit, + }; +diff --git a/src/core/swap.c b/src/core/swap.c +index 823699699e..90fcd69300 100644 +--- a/src/core/swap.c ++++ b/src/core/swap.c +@@ -851,12 +851,6 @@ static int swap_start(Unit *u) { + if (UNIT(other)->job && UNIT(other)->job->state == JOB_RUNNING) + return -EAGAIN; + +- r = unit_test_start_limit(u); +- if (r < 0) { +- swap_enter_dead(s, SWAP_FAILURE_START_LIMIT_HIT); +- return r; +- } +- + r = unit_acquire_invocation_id(u); + if (r < 0) + return r; +@@ -1458,6 +1452,21 @@ static int swap_control_pid(Unit *u) { + return s->control_pid; + } + ++static int swap_test_start_limit(Unit *u) { ++ Swap *s = SWAP(u); ++ int r; ++ ++ assert(s); ++ ++ r = unit_test_start_limit(u); ++ if (r < 0) { ++ swap_enter_dead(s, SWAP_FAILURE_START_LIMIT_HIT); ++ return r; ++ } ++ ++ return 0; ++} ++ + static const char* const swap_exec_command_table[_SWAP_EXEC_COMMAND_MAX] = { + [SWAP_EXEC_ACTIVATE] = "ExecActivate", + [SWAP_EXEC_DEACTIVATE] = "ExecDeactivate", +@@ -1547,4 +1556,6 @@ const UnitVTable swap_vtable = { + [JOB_TIMEOUT] = "Timed out deactivating swap %s.", + }, + }, ++ ++ .test_start_limit = swap_test_start_limit, + }; +diff --git a/src/core/timer.c b/src/core/timer.c +index be16321296..fb9ae17990 100644 +--- a/src/core/timer.c ++++ b/src/core/timer.c +@@ -599,12 +599,6 @@ static int timer_start(Unit *u) { + return -ENOENT; + } + +- r = unit_test_start_limit(u); +- if (r < 0) { +- timer_enter_dead(t, TIMER_FAILURE_START_LIMIT_HIT); +- return r; +- } +- + r = unit_acquire_invocation_id(u); + if (r < 0) + return r; +@@ -829,6 +823,21 @@ static void timer_timezone_change(Unit *u) { + timer_enter_waiting(t, false); + } + ++static int timer_test_start_limit(Unit *u) { ++ Timer *t = TIMER(u); ++ int r; ++ ++ assert(t); ++ ++ r = unit_test_start_limit(u); ++ if (r < 0) { ++ timer_enter_dead(t, TIMER_FAILURE_START_LIMIT_HIT); ++ return r; ++ } ++ ++ return 0; ++} ++ + static const char* const timer_base_table[_TIMER_BASE_MAX] = { + [TIMER_ACTIVE] = "OnActiveSec", + [TIMER_BOOT] = "OnBootSec", +@@ -884,4 +893,5 @@ const UnitVTable timer_vtable = { + .bus_set_property = bus_timer_set_property, + + .can_transient = true, ++ .test_start_limit = timer_test_start_limit, + }; +diff --git a/src/core/unit.c b/src/core/unit.c +index fa94a67fdd..9005f79df3 100644 +--- a/src/core/unit.c ++++ b/src/core/unit.c +@@ -1726,10 +1726,16 @@ int unit_start(Unit *u) { + + assert(u); + +- /* If this is already started, then this will succeed. Note +- * that this will even succeed if this unit is not startable +- * by the user. This is relied on to detect when we need to +- * wait for units and when waiting is finished. */ ++ /* Check start rate limiting early so that failure conditions don't cause us to enter a busy loop. */ ++ if (UNIT_VTABLE(u)->test_start_limit) { ++ int r = UNIT_VTABLE(u)->test_start_limit(u); ++ if (r < 0) ++ return r; ++ } ++ ++ /* If this is already started, then this will succeed. Note that this will even succeed if this unit ++ * is not startable by the user. This is relied on to detect when we need to wait for units and when ++ * waiting is finished. */ + state = unit_active_state(u); + if (UNIT_IS_ACTIVE_OR_RELOADING(state)) + return -EALREADY; +diff --git a/src/core/unit.h b/src/core/unit.h +index a8bc350b66..9e6f1bcf81 100644 +--- a/src/core/unit.h ++++ b/src/core/unit.h +@@ -567,6 +567,10 @@ typedef struct UnitVTable { + /* The bus vtable */ + const sd_bus_vtable *bus_vtable; + ++ /* If this function is set, it's invoked first as part of starting a unit to allow start rate ++ * limiting checks to occur before we do anything else. */ ++ int (*test_start_limit)(Unit *u); ++ + /* The strings to print in status messages */ + UnitStatusMessageFormats status_message_formats; + diff --git a/SOURCES/0678-sd-event-introduce-callback-invoked-when-event-sourc.patch b/SOURCES/0678-sd-event-introduce-callback-invoked-when-event-sourc.patch new file mode 100644 index 0000000..c8b8338 --- /dev/null +++ b/SOURCES/0678-sd-event-introduce-callback-invoked-when-event-sourc.patch @@ -0,0 +1,226 @@ +From 5f2ee8632f15a8978c522de6789777171e898671 Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +Date: Mon, 4 Oct 2021 19:44:06 +0200 +Subject: [PATCH] sd-event: introduce callback invoked when event source + ratelimit expires + +(cherry picked from commit fd69f2247520b0be3190ded96d646a415edc97b7) + +Related: #2037395 +--- + src/libsystemd/libsystemd.sym | 5 +++ + src/libsystemd/sd-event/sd-event.c | 61 +++++++++++++++++++++++----- + src/libsystemd/sd-event/test-event.c | 12 ++++++ + src/systemd/sd-event.h | 1 + + 4 files changed, 68 insertions(+), 11 deletions(-) + +diff --git a/src/libsystemd/libsystemd.sym b/src/libsystemd/libsystemd.sym +index 149d2e7b82..f4a1426248 100644 +--- a/src/libsystemd/libsystemd.sym ++++ b/src/libsystemd/libsystemd.sym +@@ -579,3 +579,8 @@ global: + sd_event_source_get_ratelimit; + sd_event_source_is_ratelimited; + } LIBSYSTEMD_239; ++ ++LIBSYSTEMD_250 { ++global: ++ sd_event_source_set_ratelimit_expire_callback; ++} LIBSYSTEMD_248; +diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c +index 47cf93b3f4..0adfdd9e1a 100644 +--- a/src/libsystemd/sd-event/sd-event.c ++++ b/src/libsystemd/sd-event/sd-event.c +@@ -125,6 +125,7 @@ struct sd_event_source { + uint64_t prepare_iteration; + + sd_event_destroy_t destroy_callback; ++ sd_event_handler_t ratelimit_expire_callback; + + LIST_FIELDS(sd_event_source, sources); + +@@ -2734,7 +2735,7 @@ fail: + return r; + } + +-static int event_source_leave_ratelimit(sd_event_source *s) { ++static int event_source_leave_ratelimit(sd_event_source *s, bool run_callback) { + int r; + + assert(s); +@@ -2766,6 +2767,23 @@ static int event_source_leave_ratelimit(sd_event_source *s) { + ratelimit_reset(&s->rate_limit); + + log_debug("Event source %p (%s) left rate limit state.", s, strna(s->description)); ++ ++ if (run_callback && s->ratelimit_expire_callback) { ++ s->dispatching = true; ++ r = s->ratelimit_expire_callback(s, s->userdata); ++ s->dispatching = false; ++ ++ if (r < 0) { ++ log_debug_errno(r, "Ratelimit expiry callback of event source %s (type %s) returned error, disabling: %m", ++ strna(s->description), ++ event_source_type_to_string(s->type)); ++ ++ sd_event_source_set_enabled(s, SD_EVENT_OFF); ++ } ++ ++ return 1; ++ } ++ + return 0; + + fail: +@@ -2966,6 +2984,7 @@ static int process_timer( + struct clock_data *d) { + + sd_event_source *s; ++ bool callback_invoked = false; + int r; + + assert(e); +@@ -2981,9 +3000,11 @@ static int process_timer( + * again. */ + assert(s->ratelimited); + +- r = event_source_leave_ratelimit(s); ++ r = event_source_leave_ratelimit(s, /* run_callback */ true); + if (r < 0) + return r; ++ else if (r == 1) ++ callback_invoked = true; + + continue; + } +@@ -2998,7 +3019,7 @@ static int process_timer( + event_source_time_prioq_reshuffle(s); + } + +- return 0; ++ return callback_invoked; + } + + static int process_child(sd_event *e) { +@@ -3698,15 +3719,15 @@ _public_ int sd_event_wait(sd_event *e, uint64_t timeout) { + if (r < 0) + goto finish; + +- r = process_timer(e, e->timestamp.realtime, &e->realtime); ++ r = process_inotify(e); + if (r < 0) + goto finish; + +- r = process_timer(e, e->timestamp.boottime, &e->boottime); ++ r = process_timer(e, e->timestamp.realtime, &e->realtime); + if (r < 0) + goto finish; + +- r = process_timer(e, e->timestamp.monotonic, &e->monotonic); ++ r = process_timer(e, e->timestamp.boottime, &e->boottime); + if (r < 0) + goto finish; + +@@ -3718,16 +3739,27 @@ _public_ int sd_event_wait(sd_event *e, uint64_t timeout) { + if (r < 0) + goto finish; + ++ r = process_timer(e, e->timestamp.monotonic, &e->monotonic); ++ if (r < 0) ++ goto finish; ++ else if (r == 1) { ++ /* Ratelimit expiry callback was called. Let's postpone processing pending sources and ++ * put loop in the initial state in order to evaluate (in the next iteration) also sources ++ * there were potentially re-enabled by the callback. ++ * ++ * Wondering why we treat only this invocation of process_timer() differently? Once event ++ * source is ratelimited we essentially transform it into CLOCK_MONOTONIC timer hence ++ * ratelimit expiry callback is never called for any other timer type. */ ++ r = 0; ++ goto finish; ++ } ++ + if (e->need_process_child) { + r = process_child(e); + if (r < 0) + goto finish; + } + +- r = process_inotify(e); +- if (r < 0) +- goto finish; +- + if (event_next_pending(e)) { + e->state = SD_EVENT_PENDING; + +@@ -4054,7 +4086,7 @@ _public_ int sd_event_source_set_ratelimit(sd_event_source *s, uint64_t interval + + /* When ratelimiting is configured we'll always reset the rate limit state first and start fresh, + * non-ratelimited. */ +- r = event_source_leave_ratelimit(s); ++ r = event_source_leave_ratelimit(s, /* run_callback */ false); + if (r < 0) + return r; + +@@ -4062,6 +4094,13 @@ _public_ int sd_event_source_set_ratelimit(sd_event_source *s, uint64_t interval + return 0; + } + ++_public_ int sd_event_source_set_ratelimit_expire_callback(sd_event_source *s, sd_event_handler_t callback) { ++ assert_return(s, -EINVAL); ++ ++ s->ratelimit_expire_callback = callback; ++ return 0; ++} ++ + _public_ int sd_event_source_get_ratelimit(sd_event_source *s, uint64_t *ret_interval, unsigned *ret_burst) { + assert_return(s, -EINVAL); + +diff --git a/src/libsystemd/sd-event/test-event.c b/src/libsystemd/sd-event/test-event.c +index e3ee4cd5c3..9135b22839 100644 +--- a/src/libsystemd/sd-event/test-event.c ++++ b/src/libsystemd/sd-event/test-event.c +@@ -506,6 +506,11 @@ static int ratelimit_time_handler(sd_event_source *s, uint64_t usec, void *userd + return 0; + } + ++static int expired = -1; ++static int ratelimit_expired(sd_event_source *s, void *userdata) { ++ return ++expired; ++} ++ + static void test_ratelimit(void) { + _cleanup_close_pair_ int p[2] = {-1, -1}; + _cleanup_(sd_event_unrefp) sd_event *e = NULL; +@@ -568,12 +573,19 @@ static void test_ratelimit(void) { + + assert_se(sd_event_source_set_ratelimit(s, 1 * USEC_PER_SEC, 10) >= 0); + ++ /* Set callback that will be invoked when we leave rate limited state. */ ++ assert_se(sd_event_source_set_ratelimit_expire_callback(s, ratelimit_expired) >= 0); ++ + do { + assert_se(sd_event_run(e, UINT64_MAX) >= 0); + } while (!sd_event_source_is_ratelimited(s)); + + log_info("ratelimit_time_handler: called 10 more times, event source got ratelimited"); + assert_se(count == 20); ++ ++ /* Dispatch the event loop once more and check that ratelimit expiration callback got called */ ++ assert_se(sd_event_run(e, UINT64_MAX) >= 0); ++ assert_se(expired == 0); + } + + int main(int argc, char *argv[]) { +diff --git a/src/systemd/sd-event.h b/src/systemd/sd-event.h +index a17a9b3488..c2e9c9614d 100644 +--- a/src/systemd/sd-event.h ++++ b/src/systemd/sd-event.h +@@ -147,6 +147,7 @@ int sd_event_source_get_destroy_callback(sd_event_source *s, sd_event_destroy_t + int sd_event_source_set_ratelimit(sd_event_source *s, uint64_t interval_usec, unsigned burst); + int sd_event_source_get_ratelimit(sd_event_source *s, uint64_t *ret_interval_usec, unsigned *ret_burst); + int sd_event_source_is_ratelimited(sd_event_source *s); ++int sd_event_source_set_ratelimit_expire_callback(sd_event_source *s, sd_event_handler_t callback); + + /* Define helpers so that __attribute__((cleanup(sd_event_unrefp))) and similar may be used. */ + _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_event, sd_event_unref); diff --git a/SOURCES/0679-core-rename-generalize-UNIT-u-test_start_limit-hook.patch b/SOURCES/0679-core-rename-generalize-UNIT-u-test_start_limit-hook.patch new file mode 100644 index 0000000..f3b520b --- /dev/null +++ b/SOURCES/0679-core-rename-generalize-UNIT-u-test_start_limit-hook.patch @@ -0,0 +1,263 @@ +From c08bb8f464ff4d27fbf762d19d28fe92955a668d Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +Date: Mon, 4 Oct 2021 17:51:52 +0200 +Subject: [PATCH] core: rename/generalize UNIT(u)->test_start_limit() hook + +Up until now the main reason why we didn't proceed with starting the +unit was exceed start limit burst. However, for unit types like mounts +the other reason could be effective ratelimit on /proc/self/mountinfo +event source. That means our mount unit state may not reflect current +kernel state. Hence, we need to attempt to re-run the start job again +after ratelimit on event source expires. + +As we will be introducing another reason than start limit let's rename +the virtual function that implements the check. + +(cherry picked from commit 705578c3b9d794097233aa66010cf67b2a444716) + +Related: #2037395 +--- + src/core/automount.c | 6 +++--- + src/core/mount.c | 6 +++--- + src/core/path.c | 6 +++--- + src/core/service.c | 6 +++--- + src/core/socket.c | 6 +++--- + src/core/swap.c | 6 +++--- + src/core/timer.c | 6 +++--- + src/core/unit.c | 6 +++--- + src/core/unit.h | 2 +- + 9 files changed, 25 insertions(+), 25 deletions(-) + +diff --git a/src/core/automount.c b/src/core/automount.c +index 5e16adabb5..f212620c8f 100644 +--- a/src/core/automount.c ++++ b/src/core/automount.c +@@ -1071,7 +1071,7 @@ static bool automount_supported(void) { + return supported; + } + +-static int automount_test_start_limit(Unit *u) { ++static int automount_can_start(Unit *u) { + Automount *a = AUTOMOUNT(u); + int r; + +@@ -1083,7 +1083,7 @@ static int automount_test_start_limit(Unit *u) { + return r; + } + +- return 0; ++ return 1; + } + + static const char* const automount_result_table[_AUTOMOUNT_RESULT_MAX] = { +@@ -1145,5 +1145,5 @@ const UnitVTable automount_vtable = { + }, + }, + +- .test_start_limit = automount_test_start_limit, ++ .can_start = automount_can_start, + }; +diff --git a/src/core/mount.c b/src/core/mount.c +index 619f64d5b7..72341fe685 100644 +--- a/src/core/mount.c ++++ b/src/core/mount.c +@@ -1947,7 +1947,7 @@ static int mount_control_pid(Unit *u) { + return m->control_pid; + } + +-static int mount_test_start_limit(Unit *u) { ++static int mount_can_start(Unit *u) { + Mount *m = MOUNT(u); + int r; + +@@ -1959,7 +1959,7 @@ static int mount_test_start_limit(Unit *u) { + return r; + } + +- return 0; ++ return 1; + } + + static const char* const mount_exec_command_table[_MOUNT_EXEC_COMMAND_MAX] = { +@@ -2054,5 +2054,5 @@ const UnitVTable mount_vtable = { + }, + }, + +- .test_start_limit = mount_test_start_limit, ++ .can_start = mount_can_start, + }; +diff --git a/src/core/path.c b/src/core/path.c +index 1e69a1f05f..58f490589d 100644 +--- a/src/core/path.c ++++ b/src/core/path.c +@@ -724,7 +724,7 @@ static void path_reset_failed(Unit *u) { + p->result = PATH_SUCCESS; + } + +-static int path_test_start_limit(Unit *u) { ++static int path_can_start(Unit *u) { + Path *p = PATH(u); + int r; + +@@ -736,7 +736,7 @@ static int path_test_start_limit(Unit *u) { + return r; + } + +- return 0; ++ return 1; + } + + static const char* const path_type_table[_PATH_TYPE_MAX] = { +@@ -792,5 +792,5 @@ const UnitVTable path_vtable = { + .bus_vtable = bus_path_vtable, + .bus_set_property = bus_path_set_property, + +- .test_start_limit = path_test_start_limit, ++ .can_start = path_can_start, + }; +diff --git a/src/core/service.c b/src/core/service.c +index a21d98ab8f..2b7e85d3eb 100644 +--- a/src/core/service.c ++++ b/src/core/service.c +@@ -4043,7 +4043,7 @@ static bool service_needs_console(Unit *u) { + SERVICE_FINAL_SIGKILL); + } + +-static int service_test_start_limit(Unit *u) { ++static int service_can_start(Unit *u) { + Service *s = SERVICE(u); + int r; + +@@ -4056,7 +4056,7 @@ static int service_test_start_limit(Unit *u) { + return r; + } + +- return 0; ++ return 1; + } + + static const char* const service_restart_table[_SERVICE_RESTART_MAX] = { +@@ -4201,5 +4201,5 @@ const UnitVTable service_vtable = { + }, + }, + +- .test_start_limit = service_test_start_limit, ++ .can_start = service_can_start, + }; +diff --git a/src/core/socket.c b/src/core/socket.c +index 36d2e4f823..3589300e68 100644 +--- a/src/core/socket.c ++++ b/src/core/socket.c +@@ -3261,7 +3261,7 @@ static int socket_control_pid(Unit *u) { + return s->control_pid; + } + +-static int socket_test_start_limit(Unit *u) { ++static int socket_can_start(Unit *u) { + Socket *s = SOCKET(u); + int r; + +@@ -3273,7 +3273,7 @@ static int socket_test_start_limit(Unit *u) { + return r; + } + +- return 0; ++ return 1; + } + + static const char* const socket_exec_command_table[_SOCKET_EXEC_COMMAND_MAX] = { +@@ -3369,5 +3369,5 @@ const UnitVTable socket_vtable = { + }, + }, + +- .test_start_limit = socket_test_start_limit, ++ .can_start = socket_can_start, + }; +diff --git a/src/core/swap.c b/src/core/swap.c +index 90fcd69300..498c5a6d69 100644 +--- a/src/core/swap.c ++++ b/src/core/swap.c +@@ -1452,7 +1452,7 @@ static int swap_control_pid(Unit *u) { + return s->control_pid; + } + +-static int swap_test_start_limit(Unit *u) { ++static int swap_can_start(Unit *u) { + Swap *s = SWAP(u); + int r; + +@@ -1464,7 +1464,7 @@ static int swap_test_start_limit(Unit *u) { + return r; + } + +- return 0; ++ return 1; + } + + static const char* const swap_exec_command_table[_SWAP_EXEC_COMMAND_MAX] = { +@@ -1557,5 +1557,5 @@ const UnitVTable swap_vtable = { + }, + }, + +- .test_start_limit = swap_test_start_limit, ++ .can_start = swap_can_start, + }; +diff --git a/src/core/timer.c b/src/core/timer.c +index fb9ae17990..684180bf99 100644 +--- a/src/core/timer.c ++++ b/src/core/timer.c +@@ -823,7 +823,7 @@ static void timer_timezone_change(Unit *u) { + timer_enter_waiting(t, false); + } + +-static int timer_test_start_limit(Unit *u) { ++static int timer_can_start(Unit *u) { + Timer *t = TIMER(u); + int r; + +@@ -835,7 +835,7 @@ static int timer_test_start_limit(Unit *u) { + return r; + } + +- return 0; ++ return 1; + } + + static const char* const timer_base_table[_TIMER_BASE_MAX] = { +@@ -893,5 +893,5 @@ const UnitVTable timer_vtable = { + .bus_set_property = bus_timer_set_property, + + .can_transient = true, +- .test_start_limit = timer_test_start_limit, ++ .can_start = timer_can_start, + }; +diff --git a/src/core/unit.c b/src/core/unit.c +index 9005f79df3..bd0a6bb7cc 100644 +--- a/src/core/unit.c ++++ b/src/core/unit.c +@@ -1726,9 +1726,9 @@ int unit_start(Unit *u) { + + assert(u); + +- /* Check start rate limiting early so that failure conditions don't cause us to enter a busy loop. */ +- if (UNIT_VTABLE(u)->test_start_limit) { +- int r = UNIT_VTABLE(u)->test_start_limit(u); ++ /* Check our ability to start early so that failure conditions don't cause us to enter a busy loop. */ ++ if (UNIT_VTABLE(u)->can_start) { ++ int r = UNIT_VTABLE(u)->can_start(u); + if (r < 0) + return r; + } +diff --git a/src/core/unit.h b/src/core/unit.h +index 9e6f1bcf81..0cd259411f 100644 +--- a/src/core/unit.h ++++ b/src/core/unit.h +@@ -569,7 +569,7 @@ typedef struct UnitVTable { + + /* If this function is set, it's invoked first as part of starting a unit to allow start rate + * limiting checks to occur before we do anything else. */ +- int (*test_start_limit)(Unit *u); ++ int (*can_start)(Unit *u); + + /* The strings to print in status messages */ + UnitStatusMessageFormats status_message_formats; diff --git a/SOURCES/0680-mount-make-mount-units-start-jobs-not-runnable-if-p-.patch b/SOURCES/0680-mount-make-mount-units-start-jobs-not-runnable-if-p-.patch new file mode 100644 index 0000000..7d21e32 --- /dev/null +++ b/SOURCES/0680-mount-make-mount-units-start-jobs-not-runnable-if-p-.patch @@ -0,0 +1,27 @@ +From faaac88f0686066e0b930952f12010f6d93fd6cf Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +Date: Mon, 4 Oct 2021 19:41:34 +0200 +Subject: [PATCH] mount: make mount units start jobs not runnable if + /p/s/mountinfo ratelimit is in effect + +(cherry picked from commit a7c93dfe91e88a5a561341c523a45c7f8d71a588) + +Related: #2037395 +--- + src/core/mount.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/core/mount.c b/src/core/mount.c +index 72341fe685..dbac1b7cb1 100644 +--- a/src/core/mount.c ++++ b/src/core/mount.c +@@ -1953,6 +1953,9 @@ static int mount_can_start(Unit *u) { + + assert(m); + ++ if (sd_event_source_is_ratelimited(u->manager->mount_event_source)) ++ return -EAGAIN; ++ + r = unit_test_start_limit(u); + if (r < 0) { + mount_enter_dead(m, MOUNT_FAILURE_START_LIMIT_HIT); diff --git a/SOURCES/0681-mount-retrigger-run-queue-after-ratelimit-expired-to.patch b/SOURCES/0681-mount-retrigger-run-queue-after-ratelimit-expired-to.patch new file mode 100644 index 0000000..6887e73 --- /dev/null +++ b/SOURCES/0681-mount-retrigger-run-queue-after-ratelimit-expired-to.patch @@ -0,0 +1,54 @@ +From 0b28134258e40b2fc054326175317db65c23bcd6 Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +Date: Mon, 4 Oct 2021 20:31:49 +0200 +Subject: [PATCH] mount: retrigger run queue after ratelimit expired to run + delayed mount start jobs + +Fixes #20329 + +(cherry picked from commit edc027b4f1cfaa49e8ecdde763eb8c623402d464) + +Related: #2037395 +--- + src/core/mount.c | 21 +++++++++++++++++++++ + 1 file changed, 21 insertions(+) + +diff --git a/src/core/mount.c b/src/core/mount.c +index dbac1b7cb1..c05779343c 100644 +--- a/src/core/mount.c ++++ b/src/core/mount.c +@@ -1706,6 +1706,21 @@ static bool mount_is_mounted(Mount *m) { + return UNIT(m)->perpetual || m->is_mounted; + } + ++static int mount_on_ratelimit_expire(sd_event_source *s, void *userdata) { ++ Manager *m = userdata; ++ int r; ++ ++ assert(m); ++ ++ /* By entering ratelimited state we made all mount start jobs not runnable, now rate limit is over so let's ++ * make sure we dispatch them in the next iteration. */ ++ r = sd_event_source_set_enabled(m->run_queue_event_source, SD_EVENT_ONESHOT); ++ if (r < 0) ++ log_debug_errno(r, "Failed to enable run queue event source, ignoring: %m"); ++ ++ return 0; ++} ++ + static void mount_enumerate(Manager *m) { + int r; + +@@ -1759,6 +1774,12 @@ static void mount_enumerate(Manager *m) { + goto fail; + } + ++ r = sd_event_source_set_ratelimit_expire_callback(m->mount_event_source, mount_on_ratelimit_expire); ++ if (r < 0) { ++ log_error_errno(r, "Failed to enable rate limit for mount events: %m"); ++ goto fail; ++ } ++ + (void) sd_event_source_set_description(m->mount_event_source, "mount-monitor-dispatch"); + } + diff --git a/SOURCES/0682-pid1-add-a-manager_trigger_run_queue-helper.patch b/SOURCES/0682-pid1-add-a-manager_trigger_run_queue-helper.patch new file mode 100644 index 0000000..2c12d00 --- /dev/null +++ b/SOURCES/0682-pid1-add-a-manager_trigger_run_queue-helper.patch @@ -0,0 +1,98 @@ +From 567c8855016ee5e7641d6c5f1ed84badd9fae10d Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 12 Nov 2021 09:43:07 +0100 +Subject: [PATCH] pid1: add a manager_trigger_run_queue() helper + +We have two different places where we re-trigger the run queue now. +let's unify it under a common function, that is part of the Manager +code. + +Follow-up for #20953 + +(cherry picked from commit b0c4b2824693fe6a27ea9439ec7a6328a0e23704) + +Related: #2037395 +--- + src/core/job.c | 5 ++--- + src/core/manager.c | 12 ++++++++++++ + src/core/manager.h | 2 ++ + src/core/mount.c | 9 +++------ + 4 files changed, 19 insertions(+), 9 deletions(-) + +diff --git a/src/core/job.c b/src/core/job.c +index 870ec0a387..cc6e1ee65a 100644 +--- a/src/core/job.c ++++ b/src/core/job.c +@@ -1137,11 +1137,10 @@ void job_add_to_run_queue(Job *j) { + if (j->in_run_queue) + return; + +- if (!j->manager->run_queue) +- sd_event_source_set_enabled(j->manager->run_queue_event_source, SD_EVENT_ONESHOT); +- + LIST_PREPEND(run_queue, j->manager->run_queue, j); + j->in_run_queue = true; ++ ++ manager_trigger_run_queue(j->manager); + } + + void job_add_to_dbus_queue(Job *j) { +diff --git a/src/core/manager.c b/src/core/manager.c +index 3c44ad3dbc..ae6ce35d99 100644 +--- a/src/core/manager.c ++++ b/src/core/manager.c +@@ -2120,6 +2120,18 @@ static int manager_dispatch_run_queue(sd_event_source *source, void *userdata) { + return 1; + } + ++void manager_trigger_run_queue(Manager *m) { ++ int r; ++ ++ assert(m); ++ ++ r = sd_event_source_set_enabled( ++ m->run_queue_event_source, ++ m->run_queue ? SD_EVENT_ONESHOT: SD_EVENT_OFF); ++ if (r < 0) ++ log_warning_errno(r, "Failed to enable job run queue event source, ignoring: %m"); ++} ++ + static unsigned manager_dispatch_dbus_queue(Manager *m) { + unsigned n = 0, budget; + Unit *u; +diff --git a/src/core/manager.h b/src/core/manager.h +index c4b8e80093..7b572c8dfd 100644 +--- a/src/core/manager.h ++++ b/src/core/manager.h +@@ -416,6 +416,8 @@ unsigned manager_dispatch_load_queue(Manager *m); + int manager_environment_add(Manager *m, char **minus, char **plus); + int manager_set_default_rlimits(Manager *m, struct rlimit **default_rlimit); + ++void manager_trigger_run_queue(Manager *m); ++ + int manager_loop(Manager *m); + + int manager_open_serialization(Manager *m, FILE **_f); +diff --git a/src/core/mount.c b/src/core/mount.c +index c05779343c..9ff7c71edd 100644 +--- a/src/core/mount.c ++++ b/src/core/mount.c +@@ -1708,15 +1708,12 @@ static bool mount_is_mounted(Mount *m) { + + static int mount_on_ratelimit_expire(sd_event_source *s, void *userdata) { + Manager *m = userdata; +- int r; + + assert(m); + +- /* By entering ratelimited state we made all mount start jobs not runnable, now rate limit is over so let's +- * make sure we dispatch them in the next iteration. */ +- r = sd_event_source_set_enabled(m->run_queue_event_source, SD_EVENT_ONESHOT); +- if (r < 0) +- log_debug_errno(r, "Failed to enable run queue event source, ignoring: %m"); ++ /* By entering ratelimited state we made all mount start jobs not runnable, now rate limit is over so ++ * let's make sure we dispatch them in the next iteration. */ ++ manager_trigger_run_queue(m); + + return 0; + } diff --git a/SOURCES/0683-unit-add-jobs-that-were-skipped-because-of-ratelimit.patch b/SOURCES/0683-unit-add-jobs-that-were-skipped-because-of-ratelimit.patch new file mode 100644 index 0000000..af625ce --- /dev/null +++ b/SOURCES/0683-unit-add-jobs-that-were-skipped-because-of-ratelimit.patch @@ -0,0 +1,46 @@ +From a9a25019ea307741d7d42178ac0f47a2320f8e94 Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +Date: Thu, 25 Nov 2021 18:28:25 +0100 +Subject: [PATCH] unit: add jobs that were skipped because of ratelimit back to + run_queue + +Assumption in edc027b was that job we first skipped because of active +ratelimit is still in run_queue. Hence we trigger the queue and dispatch +it in the next iteration. Actually we remove jobs from run_queue in +job_run_and_invalidate() before we call unit_start(). Hence if we want +to attempt to run the job again in the future we need to add it back +to run_queue. + +Fixes #21458 + +(cherry picked from commit c29e6a9530316823b0455cd83eb6d0bb8dd664f4) + +Related: #2037395 +--- + src/core/mount.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/src/core/mount.c b/src/core/mount.c +index 9ff7c71edd..4e0a4f238a 100644 +--- a/src/core/mount.c ++++ b/src/core/mount.c +@@ -1708,9 +1708,19 @@ static bool mount_is_mounted(Mount *m) { + + static int mount_on_ratelimit_expire(sd_event_source *s, void *userdata) { + Manager *m = userdata; ++ Job *j; ++ Iterator i; + + assert(m); + ++ /* Let's enqueue all start jobs that were previously skipped because of active ratelimit. */ ++ HASHMAP_FOREACH(j, m->jobs, i) { ++ if (j->unit->type != UNIT_MOUNT) ++ continue; ++ ++ job_add_to_run_queue(j); ++ } ++ + /* By entering ratelimited state we made all mount start jobs not runnable, now rate limit is over so + * let's make sure we dispatch them in the next iteration. */ + manager_trigger_run_queue(m); diff --git a/SOURCES/0684-udev-net_id-introduce-naming-scheme-for-RHEL-8.5.patch b/SOURCES/0684-udev-net_id-introduce-naming-scheme-for-RHEL-8.5.patch new file mode 100644 index 0000000..b0cbf3c --- /dev/null +++ b/SOURCES/0684-udev-net_id-introduce-naming-scheme-for-RHEL-8.5.patch @@ -0,0 +1,50 @@ +From 6882d94ae68468b414597696727108d588402f43 Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +Date: Wed, 12 Jan 2022 15:35:19 +0100 +Subject: [PATCH] udev/net_id: introduce naming scheme for RHEL-8.5 + +RHEL-only + +Related: #2040244 +--- + man/systemd.net-naming-scheme.xml | 6 ++++++ + src/udev/udev-builtin-net_id.c | 2 ++ + 2 files changed, 8 insertions(+) + +diff --git a/man/systemd.net-naming-scheme.xml b/man/systemd.net-naming-scheme.xml +index 10e71dcb15..be969bc8d0 100644 +--- a/man/systemd.net-naming-scheme.xml ++++ b/man/systemd.net-naming-scheme.xml +@@ -301,6 +301,12 @@ + avoid possible naming conflict. + + ++ ++ rhel-8.5 ++ ++ Same as naming scheme rhel-8.4. ++ ++ + Note that latest may be used to denote the latest scheme known (to this + particular version of systemd. + +diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c +index 0611c08234..3a0b3b1eae 100644 +--- a/src/udev/udev-builtin-net_id.c ++++ b/src/udev/udev-builtin-net_id.c +@@ -135,6 +135,7 @@ typedef enum NamingSchemeFlags { + NAMING_RHEL_8_2 = NAMING_V239, + NAMING_RHEL_8_3 = NAMING_V239, + NAMING_RHEL_8_4 = NAMING_V239|NAMING_BRIDGE_NO_SLOT, ++ NAMING_RHEL_8_5 = NAMING_RHEL_8_4, + + _NAMING_SCHEME_FLAGS_INVALID = -1, + } NamingSchemeFlags; +@@ -152,6 +153,7 @@ static const NamingScheme naming_schemes[] = { + { "rhel-8.2", NAMING_RHEL_8_2 }, + { "rhel-8.3", NAMING_RHEL_8_3 }, + { "rhel-8.4", NAMING_RHEL_8_4 }, ++ { "rhel-8.5", NAMING_RHEL_8_5 }, + /* … add more schemes here, as the logic to name devices is updated … */ + }; + diff --git a/SOURCES/0685-udev-net_id-remove-extraneous-bracket.patch b/SOURCES/0685-udev-net_id-remove-extraneous-bracket.patch new file mode 100644 index 0000000..3c454f7 --- /dev/null +++ b/SOURCES/0685-udev-net_id-remove-extraneous-bracket.patch @@ -0,0 +1,25 @@ +From d5d728d24b34194438e74580c1a58f5727b59444 Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +Date: Wed, 12 Jan 2022 15:35:54 +0100 +Subject: [PATCH] udev/net_id: remove extraneous bracket + +RHEL-only + +Related: #2040244 +--- + man/systemd.net-naming-scheme.xml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/man/systemd.net-naming-scheme.xml b/man/systemd.net-naming-scheme.xml +index be969bc8d0..a65da5c6c1 100644 +--- a/man/systemd.net-naming-scheme.xml ++++ b/man/systemd.net-naming-scheme.xml +@@ -307,7 +307,7 @@ + Same as naming scheme rhel-8.4. + + +- Note that latest may be used to denote the latest scheme known (to this ++ Note that latest may be used to denote the latest scheme known to this + particular version of systemd. + + diff --git a/SOURCES/0686-mount-do-not-update-exec-deps-on-mountinfo-changes.patch b/SOURCES/0686-mount-do-not-update-exec-deps-on-mountinfo-changes.patch new file mode 100644 index 0000000..01bf38f --- /dev/null +++ b/SOURCES/0686-mount-do-not-update-exec-deps-on-mountinfo-changes.patch @@ -0,0 +1,87 @@ +From 9807f473b1b3e2aaf86bcbc6e6b9ad1328548b22 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 15 Nov 2019 14:00:54 +0100 +Subject: [PATCH] mount: do not update exec deps on mountinfo changes + +Fixes: #13978 +(cherry picked from commit bf7eedbf8f8c83d9e775c80275f98f506ec963c6) + +Related: #2038878 +--- + src/core/mount.c | 42 ++++++++++++++++++++++++++++-------------- + 1 file changed, 28 insertions(+), 14 deletions(-) + +diff --git a/src/core/mount.c b/src/core/mount.c +index 4e0a4f238a..73c0531158 100644 +--- a/src/core/mount.c ++++ b/src/core/mount.c +@@ -535,6 +535,32 @@ static int mount_verify(Mount *m) { + return 0; + } + ++static int mount_add_non_exec_dependencies(Mount *m) { ++ int r; ++ assert(m); ++ ++ /* Adds in all dependencies directly responsible for ordering the mount, as opposed to dependencies ++ * resulting from the ExecContext and such. */ ++ ++ r = mount_add_device_dependencies(m); ++ if (r < 0) ++ return r; ++ ++ r = mount_add_mount_dependencies(m); ++ if (r < 0) ++ return r; ++ ++ r = mount_add_quota_dependencies(m); ++ if (r < 0) ++ return r; ++ ++ r = mount_add_default_dependencies(m); ++ if (r < 0) ++ return r; ++ ++ return 0; ++} ++ + static int mount_add_extras(Mount *m) { + Unit *u = UNIT(m); + int r; +@@ -558,18 +584,6 @@ static int mount_add_extras(Mount *m) { + return r; + } + +- r = mount_add_device_dependencies(m); +- if (r < 0) +- return r; +- +- r = mount_add_mount_dependencies(m); +- if (r < 0) +- return r; +- +- r = mount_add_quota_dependencies(m); +- if (r < 0) +- return r; +- + r = unit_patch_contexts(u); + if (r < 0) + return r; +@@ -582,7 +596,7 @@ static int mount_add_extras(Mount *m) { + if (r < 0) + return r; + +- r = mount_add_default_dependencies(m); ++ r = mount_add_non_exec_dependencies(m); + if (r < 0) + return r; + +@@ -1526,7 +1540,7 @@ static int mount_setup_existing_unit( + } + + if (load_extras) +- return mount_add_extras(MOUNT(u)); ++ return mount_add_non_exec_dependencies(MOUNT(u)); + + return 0; + } diff --git a/SOURCES/0687-core-mount-add-implicit-unit-dependencies-even-if-wh.patch b/SOURCES/0687-core-mount-add-implicit-unit-dependencies-even-if-wh.patch new file mode 100644 index 0000000..e893fab --- /dev/null +++ b/SOURCES/0687-core-mount-add-implicit-unit-dependencies-even-if-wh.patch @@ -0,0 +1,46 @@ +From f68eeaf2809d6866f9cca3d7746795ffc3e71f46 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Sun, 29 Aug 2021 21:20:43 +0900 +Subject: [PATCH] core/mount: add implicit unit dependencies even if when mount + unit is generated from /proc/self/mountinfo + +Hopefully fixes #20566. + +(cherry picked from commit aebff2e7ce209fc2d75b894a3ae8b80f6f36ec11) + +Resolves: #2038878 +--- + src/core/mount.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/core/mount.c b/src/core/mount.c +index 73c0531158..9547cb9b29 100644 +--- a/src/core/mount.c ++++ b/src/core/mount.c +@@ -1437,6 +1437,7 @@ static int mount_setup_new_unit( + MountSetupFlags *flags) { + + MountParameters *p; ++ int r; + + assert(u); + assert(flags); +@@ -1458,7 +1459,6 @@ static int mount_setup_new_unit( + + if (!mount_is_extrinsic(MOUNT(u))) { + const char *target; +- int r; + + target = mount_is_network(p) ? SPECIAL_REMOTE_FS_TARGET : SPECIAL_LOCAL_FS_TARGET; + r = unit_add_dependency_by_name(u, UNIT_BEFORE, target, NULL, true, UNIT_DEPENDENCY_MOUNTINFO_IMPLICIT); +@@ -1470,6 +1470,10 @@ static int mount_setup_new_unit( + return r; + } + ++ r = mount_add_non_exec_dependencies(MOUNT(u)); ++ if (r < 0) ++ return r; ++ + unit_add_to_load_queue(u); + flags->is_mounted = true; + flags->just_mounted = true; diff --git a/SPECS/systemd.spec b/SPECS/systemd.spec index 6d1be0f..074c6ef 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: 51%{?dist}.2 +Release: 51%{?dist}.5 # For a breakdown of the licensing, see README License: LGPLv2+ and MIT and GPLv2+ Summary: System and Service Manager @@ -715,6 +715,28 @@ Patch0662: 0662-test-seccomp-accept-ENOSYS-from-sysctl-2-too.patch Patch0663: 0663-Disable-libpitc-to-fix-CentOS-Stream-CI.patch Patch0664: 0664-test-accept-that-char-device-0-0-can-now-be-created-.patch Patch0665: 0665-core-return-true-from-cg_is_empty-on-ENOENT.patch +Patch0666: 0666-Do-not-fail-if-the-same-alt.-name-is-set-again.patch +Patch0667: 0667-meson-avoid-bogus-meson-warning.patch +Patch0668: 0668-meson-do-not-fail-if-rsync-is-not-installed-with-mes.patch +Patch0669: 0669-mount-don-t-propagate-errors-from-mount_setup_unit-f.patch +Patch0670: 0670-test-make-TEST-47-less-racy.patch +Patch0671: 0671-macro-define-HAS_FEATURE_ADDRESS_SANITIZER-also-on-g.patch +Patch0672: 0672-tests-add-helper-function-to-autodetect-CI-environme.patch +Patch0673: 0673-strv-rework-FOREACH_STRING-macro.patch +Patch0674: 0674-test-systemctl-use-const-char-instead-of-char.patch +Patch0675: 0675-ci-pass-the-GITHUB_ACTIONS-variable-to-the-CentOS-co.patch +Patch0676: 0676-core-rename-unit_-start_limit-condition-assert-_test.patch +Patch0677: 0677-core-Check-unit-start-rate-limiting-earlier.patch +Patch0678: 0678-sd-event-introduce-callback-invoked-when-event-sourc.patch +Patch0679: 0679-core-rename-generalize-UNIT-u-test_start_limit-hook.patch +Patch0680: 0680-mount-make-mount-units-start-jobs-not-runnable-if-p-.patch +Patch0681: 0681-mount-retrigger-run-queue-after-ratelimit-expired-to.patch +Patch0682: 0682-pid1-add-a-manager_trigger_run_queue-helper.patch +Patch0683: 0683-unit-add-jobs-that-were-skipped-because-of-ratelimit.patch +Patch0684: 0684-udev-net_id-introduce-naming-scheme-for-RHEL-8.5.patch +Patch0685: 0685-udev-net_id-remove-extraneous-bracket.patch +Patch0686: 0686-mount-do-not-update-exec-deps-on-mountinfo-changes.patch +Patch0687: 0687-core-mount-add-implicit-unit-dependencies-even-if-wh.patch %ifarch %{ix86} x86_64 aarch64 @@ -1342,6 +1364,34 @@ fi %files tests -f .file-list-tests %changelog +* Tue Jan 25 2022 systemd maintenance team - 239-51.5 +- mount: do not update exec deps on mountinfo changes (#2038878) +- core/mount: add implicit unit dependencies even if when mount unit is generated from /proc/self/mountinfo (#2038878) + +* Thu Jan 13 2022 systemd maintenance team - 239-51.4 +- mount: don't propagate errors from mount_setup_unit() further up (#2039327) +- test: make TEST-47 less racy (#2039327) +- macro: define HAS_FEATURE_ADDRESS_SANITIZER also on gcc (#2039327) +- tests: add helper function to autodetect CI environments (#2039327) +- strv: rework FOREACH_STRING() macro (#2039327) +- test,systemctl: use "const char*" instead of "char*" (#2039327) +- ci: pass the $GITHUB_ACTIONS variable to the CentOS container (#2039327) +- core: rename unit_{start_limit|condition|assert}_test() to unit_test_xyz() (#2037395) +- core: Check unit start rate limiting earlier (#2037395) +- sd-event: introduce callback invoked when event source ratelimit expires (#2037395) +- core: rename/generalize UNIT(u)->test_start_limit() hook (#2037395) +- mount: make mount units start jobs not runnable if /p/s/mountinfo ratelimit is in effect (#2037395) +- mount: retrigger run queue after ratelimit expired to run delayed mount start jobs (#2037395) +- pid1: add a manager_trigger_run_queue() helper (#2037395) +- unit: add jobs that were skipped because of ratelimit back to run_queue (#2037395) +- udev/net_id: introduce naming scheme for RHEL-8.5 (#2040244) +- udev/net_id: remove extraneous bracket (#2040244) + +* Fri Dec 10 2021 systemd maintenance team - 239-51.3 +- Do not fail if the same alt. name is set again (#2030027) +- meson: avoid bogus meson warning (#2030027) +- meson: do not fail if rsync is not installed with meson 0.57.2 (#2030027) + * Fri Dec 03 2021 systemd maintenance team - 239-51.2 - core: return true from cg_is_empty* on ENOENT (#2024903)