From 32adc3a7cab85ce543d6895d644a52c6965a274c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 7 Apr 2022 11:22:08 +0200 Subject: [PATCH 1/9] core: inline an iterator variable --- src/core/locale-setup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/locale-setup.c b/src/core/locale-setup.c index 59ddb9c487..716febbefa 100644 --- a/src/core/locale-setup.c +++ b/src/core/locale-setup.c @@ -16,7 +16,6 @@ int locale_setup(char ***environment) { _cleanup_(locale_variables_freep) char *variables[_VARIABLE_LC_MAX] = {}; _cleanup_strv_free_ char **add = NULL; - LocaleVariable i; int r; r = proc_cmdline_get_key_many(PROC_CMDLINE_STRIP_RD_PREFIX, @@ -58,7 +57,7 @@ int locale_setup(char ***environment) { log_warning_errno(r, "Failed to read /etc/locale.conf: %m"); } - for (i = 0; i < _VARIABLE_LC_MAX; i++) { + for (LocaleVariable i = 0; i < _VARIABLE_LC_MAX; i++) { char *s; if (!variables[i]) From be6447b4838bd3e9fba3c0d6a4237edf8995e436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 7 Apr 2022 11:23:32 +0200 Subject: [PATCH 2/9] README: add one more kernel-version line I want to add as many as possible to show people that each kernel version has something nice to entice them to keep moving up ;) --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index 4c9d9ae1bd..3cc215f1eb 100644 --- a/README +++ b/README @@ -37,6 +37,7 @@ REQUIREMENTS: ≥ 4.10 for cgroup-bpf egress and ingress hooks ≥ 4.15 for cgroup-bpf device hook and cpu controller in cgroup v2 ≥ 4.17 for cgroup-bpf socket address hooks + ≥ 4.20 for PSI (used by systemd-oomd) ≥ 5.3 for bounded loops in BPF program ≥ 5.4 for signed Verity images ≥ 5.7 for BPF links and the BPF LSM hook From c9394f4f93b9a6baa54f9d1c953035f26dcee253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 7 Apr 2022 11:51:52 +0200 Subject: [PATCH 3/9] Move systemd_installation_has_version() to src/nspawn/ This function implements a heuristic that is only used by nspawn. It doesn't belong in basic. I opted for a new file "nspawn-utils.c", because it seems likely that we'll need some other new utilities like that in the future. No functional change. --- src/basic/path-util.c | 71 ------------------------------- src/basic/path-util.h | 2 - src/nspawn/meson.build | 7 ++++ src/nspawn/nspawn-util.c | 78 +++++++++++++++++++++++++++++++++++ src/nspawn/nspawn-util.h | 4 ++ src/nspawn/nspawn.c | 2 +- src/nspawn/test-nspawn-util.c | 19 +++++++++ src/test/test-path-util.c | 15 ------- 8 files changed, 109 insertions(+), 89 deletions(-) create mode 100644 src/nspawn/nspawn-util.c create mode 100644 src/nspawn/nspawn-util.h create mode 100644 src/nspawn/test-nspawn-util.c diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 5d93e107a7..979c6f2c9d 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -17,11 +17,8 @@ #include "extract-word.h" #include "fd-util.h" #include "fs-util.h" -#include "glob-util.h" #include "log.h" #include "macro.h" -#include "nulstr-util.h" -#include "parse-util.h" #include "path-util.h" #include "stat-util.h" #include "string-util.h" @@ -1314,74 +1311,6 @@ bool valid_device_allow_pattern(const char *path) { return valid_device_node_path(path); } -int systemd_installation_has_version(const char *root, unsigned minimal_version) { - const char *pattern; - int r; - - /* Try to guess if systemd installation is later than the specified version. This - * is hacky and likely to yield false negatives, particularly if the installation - * is non-standard. False positives should be relatively rare. - */ - - NULSTR_FOREACH(pattern, - /* /lib works for systems without usr-merge, and for systems with a sane - * usr-merge, where /lib is a symlink to /usr/lib. /usr/lib is necessary - * for Gentoo which does a merge without making /lib a symlink. - */ - "lib/systemd/libsystemd-shared-*.so\0" - "lib64/systemd/libsystemd-shared-*.so\0" - "usr/lib/systemd/libsystemd-shared-*.so\0" - "usr/lib64/systemd/libsystemd-shared-*.so\0") { - - _cleanup_strv_free_ char **names = NULL; - _cleanup_free_ char *path = NULL; - char *c; - - path = path_join(root, pattern); - if (!path) - return -ENOMEM; - - r = glob_extend(&names, path, 0); - if (r == -ENOENT) - continue; - if (r < 0) - return r; - - assert_se(c = endswith(path, "*.so")); - *c = '\0'; /* truncate the glob part */ - - STRV_FOREACH(name, names) { - /* This is most likely to run only once, hence let's not optimize anything. */ - char *t, *t2; - unsigned version; - - t = startswith(*name, path); - if (!t) - continue; - - t2 = endswith(t, ".so"); - if (!t2) - continue; - - t2[0] = '\0'; /* truncate the suffix */ - - r = safe_atou(t, &version); - if (r < 0) { - log_debug_errno(r, "Found libsystemd shared at \"%s.so\", but failed to parse version: %m", *name); - continue; - } - - log_debug("Found libsystemd shared at \"%s.so\", version %u (%s).", - *name, version, - version >= minimal_version ? "OK" : "too old"); - if (version >= minimal_version) - return true; - } - } - - return false; -} - bool dot_or_dot_dot(const char *path) { if (!path) return false; diff --git a/src/basic/path-util.h b/src/basic/path-util.h index 518f3340bf..2f55b3abb1 100644 --- a/src/basic/path-util.h +++ b/src/basic/path-util.h @@ -181,8 +181,6 @@ bool is_device_path(const char *path); bool valid_device_node_path(const char *path); bool valid_device_allow_pattern(const char *path); -int systemd_installation_has_version(const char *root, unsigned minimal_version); - bool dot_or_dot_dot(const char *path); static inline const char *skip_dev_prefix(const char *p) { diff --git a/src/nspawn/meson.build b/src/nspawn/meson.build index a42e16dd99..f6cca7099b 100644 --- a/src/nspawn/meson.build +++ b/src/nspawn/meson.build @@ -28,6 +28,8 @@ libnspawn_core_sources = files( 'nspawn-setuid.h', 'nspawn-stub-pid1.c', 'nspawn-stub-pid1.h', + 'nspawn-util.c', + 'nspawn-util.h', 'nspawn.h', ) @@ -58,6 +60,11 @@ tests += [ libshared], [libseccomp]], + [files('test-nspawn-util.c'), + [libnspawn_core, + libshared], + [libseccomp]], + [files('test-patch-uid.c'), [libnspawn_core, libshared], diff --git a/src/nspawn/nspawn-util.c b/src/nspawn/nspawn-util.c new file mode 100644 index 0000000000..7aacbb8096 --- /dev/null +++ b/src/nspawn/nspawn-util.c @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "alloc-util.h" +#include "glob-util.h" +#include "log.h" +#include "nspawn-util.h" +#include "nulstr-util.h" +#include "parse-util.h" +#include "path-util.h" +#include "string-util.h" + +int systemd_installation_has_version(const char *root, unsigned minimal_version) { + const char *pattern; + int r; + + /* Try to guess if systemd installation is later than the specified version. This + * is hacky and likely to yield false negatives, particularly if the installation + * is non-standard. False positives should be relatively rare. + */ + + NULSTR_FOREACH(pattern, + /* /lib works for systems without usr-merge, and for systems with a sane + * usr-merge, where /lib is a symlink to /usr/lib. /usr/lib is necessary + * for Gentoo which does a merge without making /lib a symlink. + */ + "lib/systemd/libsystemd-shared-*.so\0" + "lib64/systemd/libsystemd-shared-*.so\0" + "usr/lib/systemd/libsystemd-shared-*.so\0" + "usr/lib64/systemd/libsystemd-shared-*.so\0") { + + _cleanup_strv_free_ char **names = NULL; + _cleanup_free_ char *path = NULL; + char *c; + + path = path_join(root, pattern); + if (!path) + return -ENOMEM; + + r = glob_extend(&names, path, 0); + if (r == -ENOENT) + continue; + if (r < 0) + return r; + + assert_se(c = endswith(path, "*.so")); + *c = '\0'; /* truncate the glob part */ + + STRV_FOREACH(name, names) { + /* This is most likely to run only once, hence let's not optimize anything. */ + char *t, *t2; + unsigned version; + + t = startswith(*name, path); + if (!t) + continue; + + t2 = endswith(t, ".so"); + if (!t2) + continue; + + t2[0] = '\0'; /* truncate the suffix */ + + r = safe_atou(t, &version); + if (r < 0) { + log_debug_errno(r, "Found libsystemd shared at \"%s.so\", but failed to parse version: %m", *name); + continue; + } + + log_debug("Found libsystemd shared at \"%s.so\", version %u (%s).", + *name, version, + version >= minimal_version ? "OK" : "too old"); + if (version >= minimal_version) + return true; + } + } + + return false; +} diff --git a/src/nspawn/nspawn-util.h b/src/nspawn/nspawn-util.h new file mode 100644 index 0000000000..1e90862c9d --- /dev/null +++ b/src/nspawn/nspawn-util.h @@ -0,0 +1,4 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +int systemd_installation_has_version(const char *root, unsigned minimal_version); diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index aa7367c5c9..1929cd12b0 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -78,13 +78,13 @@ #include "nspawn-settings.h" #include "nspawn-setuid.h" #include "nspawn-stub-pid1.h" +#include "nspawn-util.h" #include "nspawn.h" #include "nulstr-util.h" #include "os-util.h" #include "pager.h" #include "parse-argument.h" #include "parse-util.h" -#include "path-util.h" #include "pretty-print.h" #include "process-util.h" #include "ptyfwd.h" diff --git a/src/nspawn/test-nspawn-util.c b/src/nspawn/test-nspawn-util.c new file mode 100644 index 0000000000..7d55db8934 --- /dev/null +++ b/src/nspawn/test-nspawn-util.c @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "nspawn-util.h" +#include "string-util.h" +#include "tests.h" + +TEST(systemd_installation_has_version) { + static const unsigned versions[] = {0, 231, PROJECT_VERSION, 999}; + int r; + + for (size_t i = 0; i < ELEMENTSOF(versions); i++) { + r = systemd_installation_has_version(saved_argv[1], versions[i]); + assert_se(r >= 0); + log_info("%s has systemd >= %u: %s", + saved_argv[1] ?: "Current installation", versions[i], yes_no(r)); + } +} + +DEFINE_TEST_MAIN(LOG_DEBUG); diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c index d40febef5f..4c56a7d520 100644 --- a/src/test/test-path-util.c +++ b/src/test/test-path-util.c @@ -960,21 +960,6 @@ TEST(hidden_or_backup_file) { assert_se(!hidden_or_backup_file("test.dpkg-old.foo")); } -TEST(systemd_installation_has_version) { - int r; - const unsigned versions[] = {0, 231, PROJECT_VERSION, 999}; - unsigned i; - - log_info("/* %s */", __func__); - - for (i = 0; i < ELEMENTSOF(versions); i++) { - r = systemd_installation_has_version(saved_argv[1], versions[i]); - assert_se(r >= 0); - log_info("%s has systemd >= %u: %s", - saved_argv[1] ?: "Current installation", versions[i], yes_no(r)); - } -} - TEST(skip_dev_prefix) { assert_se(streq(skip_dev_prefix("/"), "/")); assert_se(streq(skip_dev_prefix("/dev"), "")); From 7e6821ed4e09d68c45858ba463a013eb7593c2c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 7 Apr 2022 12:15:04 +0200 Subject: [PATCH 4/9] nspawn: fix comparisons of versions with non-numerical suffixes See a2b0cd3f5ab3f450e74e2085ad20372a05451c74. When -Dshared-lib-tag is used, libsystemd-shared.so and libsystemd-core.so get a suffix which breaks the parsing done by systemd_installation_has_version(). We can assume that the tag will be something like "251-rc1-1.fc37" that is currently used in Fedora. (Anything that does *not* start with the version would be completely crazy.) By switching to strverscmp_improved() we simplify the code and fix comparisons with such versions. $ build/test-nspawn-util /var/lib/machines/rawhide ... Found libsystemd shared at "/var/lib/machines/rawhide/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251-rc1-1.fc37 (OK). /var/lib/machines/rawhide has systemd >= 251: yes ... I noticed this when I started a systemd-nspawn container with Redora rawhide and got the message "Not running with unified cgroup hierarchy, LSM BPF is not supported". I thought the message is in error, but it was actually correct: nspawn was misdetecting that the container does not sport new-enough systemd to support cgroups-v2. --- src/nspawn/nspawn-util.c | 21 +++++++-------------- src/nspawn/nspawn-util.h | 2 +- src/nspawn/nspawn.c | 4 ++-- src/nspawn/test-nspawn-util.c | 10 +++++----- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/nspawn/nspawn-util.c b/src/nspawn/nspawn-util.c index 7aacbb8096..4b3bf2aa00 100644 --- a/src/nspawn/nspawn-util.c +++ b/src/nspawn/nspawn-util.c @@ -9,7 +9,7 @@ #include "path-util.h" #include "string-util.h" -int systemd_installation_has_version(const char *root, unsigned minimal_version) { +int systemd_installation_has_version(const char *root, const char *minimal_version) { const char *pattern; int r; @@ -48,7 +48,6 @@ int systemd_installation_has_version(const char *root, unsigned minimal_version) STRV_FOREACH(name, names) { /* This is most likely to run only once, hence let's not optimize anything. */ char *t, *t2; - unsigned version; t = startswith(*name, path); if (!t) @@ -57,19 +56,13 @@ int systemd_installation_has_version(const char *root, unsigned minimal_version) t2 = endswith(t, ".so"); if (!t2) continue; + *t2 = '\0'; - t2[0] = '\0'; /* truncate the suffix */ - - r = safe_atou(t, &version); - if (r < 0) { - log_debug_errno(r, "Found libsystemd shared at \"%s.so\", but failed to parse version: %m", *name); - continue; - } - - log_debug("Found libsystemd shared at \"%s.so\", version %u (%s).", - *name, version, - version >= minimal_version ? "OK" : "too old"); - if (version >= minimal_version) + r = strverscmp_improved(t, minimal_version); + log_debug("Found libsystemd shared at \"%s.so\", version %s (%s).", + *name, t, + r >= 0 ? "OK" : "too old"); + if (r >= 0) return true; } } diff --git a/src/nspawn/nspawn-util.h b/src/nspawn/nspawn-util.h index 1e90862c9d..e83cd564da 100644 --- a/src/nspawn/nspawn-util.h +++ b/src/nspawn/nspawn-util.h @@ -1,4 +1,4 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -int systemd_installation_has_version(const char *root, unsigned minimal_version); +int systemd_installation_has_version(const char *root, const char *minimal_version); diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 1929cd12b0..a5b8265303 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -509,7 +509,7 @@ static int detect_unified_cgroup_hierarchy_from_image(const char *directory) { if (r > 0) { /* Unified cgroup hierarchy support was added in 230. Unfortunately the detection * routine only detects 231, so we'll have a false negative here for 230. */ - r = systemd_installation_has_version(directory, 230); + r = systemd_installation_has_version(directory, "230"); if (r < 0) return log_error_errno(r, "Failed to determine systemd version in container: %m"); if (r > 0) @@ -518,7 +518,7 @@ static int detect_unified_cgroup_hierarchy_from_image(const char *directory) { arg_unified_cgroup_hierarchy = CGROUP_UNIFIED_NONE; } else if (cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) > 0) { /* Mixed cgroup hierarchy support was added in 233 */ - r = systemd_installation_has_version(directory, 233); + r = systemd_installation_has_version(directory, "233"); if (r < 0) return log_error_errno(r, "Failed to determine systemd version in container: %m"); if (r > 0) diff --git a/src/nspawn/test-nspawn-util.c b/src/nspawn/test-nspawn-util.c index 7d55db8934..ed68063630 100644 --- a/src/nspawn/test-nspawn-util.c +++ b/src/nspawn/test-nspawn-util.c @@ -2,17 +2,17 @@ #include "nspawn-util.h" #include "string-util.h" +#include "strv.h" #include "tests.h" TEST(systemd_installation_has_version) { - static const unsigned versions[] = {0, 231, PROJECT_VERSION, 999}; int r; - for (size_t i = 0; i < ELEMENTSOF(versions); i++) { - r = systemd_installation_has_version(saved_argv[1], versions[i]); + FOREACH_STRING(version, "0", "231", STRINGIFY(PROJECT_VERSION), "999") { + r = systemd_installation_has_version(saved_argv[1], version); assert_se(r >= 0); - log_info("%s has systemd >= %u: %s", - saved_argv[1] ?: "Current installation", versions[i], yes_no(r)); + log_info("%s has systemd >= %s: %s", + saved_argv[1] ?: "Current installation", version, yes_no(r)); } } From 0643001c2838d244a8698ea782414115034804bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 7 Apr 2022 12:33:25 +0200 Subject: [PATCH 5/9] test-nspawn-util: fix the test to actually find anything MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We would use a relative path, looking for globs like 'lib/systemd/libsystemd-shared-*.so' under the build directory, and never find anything. The test was supposed to find library in the current installation. But we cannot assume that the right library is installed, so the test only printed the result for manual inspection. Thus nobody noticed when it broke. I think it broke in c6134d3e2f1d1d17b32b6e06556cd0c5429bc78a, path-util: get rid of prefix_root(). But that commit doesn't compile because of changes in meson, so this is just a guess. Before: /* test_systemd_installation_has_version */ Current installation has systemd >= 0: no Current installation has systemd >= 231: no Current installation has systemd >= 249: no Current installation has systemd >= 999: no With the fix: $ build/test-nspawn-util /* test_systemd_installation_has_version */ Found libsystemd shared at "/lib/systemd/libsystemd-shared-245.so.so", version 245 (OK). Current installation has systemd >= 0: yes Found libsystemd shared at "/lib/systemd/libsystemd-shared-245.so.so", version 245 (OK). Current installation has systemd >= 231: yes Found libsystemd shared at "/lib/systemd/libsystemd-shared-245.so.so", version 245 (too old). Found libsystemd shared at "/lib/systemd/libsystemd-shared-251.so.so", version 251 (OK). Current installation has systemd >= 251: yes Found libsystemd shared at "/lib/systemd/libsystemd-shared-245.so.so", version 245 (too old). Found libsystemd shared at "/lib/systemd/libsystemd-shared-251.so.so", version 251 (too old). Found libsystemd shared at "/lib/systemd/libsystemd-shared-250.so.so", version 250 (too old). Found libsystemd shared at "/usr/lib/systemd/libsystemd-shared-245.so.so", version 245 (too old). Found libsystemd shared at "/usr/lib/systemd/libsystemd-shared-251.so.so", version 251 (too old). Found libsystemd shared at "/usr/lib/systemd/libsystemd-shared-250.so.so", version 250 (too old). Current installation has systemd >= 999: no $ build/test-nspawn-util /var/lib/machines/rawhide /* test_systemd_installation_has_version */ /* test_systemd_installation_has_version */ Found libsystemd shared at "/var/lib/machines/rawhide/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251 (OK). /var/lib/machines/rawhide has systemd >= 0: yes Found libsystemd shared at "/var/lib/machines/rawhide/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251 (OK). /var/lib/machines/rawhide has systemd >= 231: yes Found libsystemd shared at "/var/lib/machines/rawhide/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251 (OK). /var/lib/machines/rawhide has systemd >= 251: yes Found libsystemd shared at "/var/lib/machines/rawhide/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251 (too old). Found libsystemd shared at "/var/lib/machines/rawhide/usr/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251 (too old). /var/lib/machines/rawhide has systemd >= 999: no While at it, NULSTR_FOREACH → FOREACH_STRING. --- src/nspawn/nspawn-util.c | 12 +++++------- src/nspawn/test-nspawn-util.c | 3 +++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/nspawn/nspawn-util.c b/src/nspawn/nspawn-util.c index 4b3bf2aa00..402554fa38 100644 --- a/src/nspawn/nspawn-util.c +++ b/src/nspawn/nspawn-util.c @@ -4,13 +4,11 @@ #include "glob-util.h" #include "log.h" #include "nspawn-util.h" -#include "nulstr-util.h" #include "parse-util.h" #include "path-util.h" #include "string-util.h" int systemd_installation_has_version(const char *root, const char *minimal_version) { - const char *pattern; int r; /* Try to guess if systemd installation is later than the specified version. This @@ -18,15 +16,15 @@ int systemd_installation_has_version(const char *root, const char *minimal_versi * is non-standard. False positives should be relatively rare. */ - NULSTR_FOREACH(pattern, + FOREACH_STRING(pattern, /* /lib works for systems without usr-merge, and for systems with a sane * usr-merge, where /lib is a symlink to /usr/lib. /usr/lib is necessary * for Gentoo which does a merge without making /lib a symlink. */ - "lib/systemd/libsystemd-shared-*.so\0" - "lib64/systemd/libsystemd-shared-*.so\0" - "usr/lib/systemd/libsystemd-shared-*.so\0" - "usr/lib64/systemd/libsystemd-shared-*.so\0") { + "/lib/systemd/libsystemd-shared-*.so", + "/lib64/systemd/libsystemd-shared-*.so", + "/usr/lib/systemd/libsystemd-shared-*.so", + "/usr/lib64/systemd/libsystemd-shared-*.so") { _cleanup_strv_free_ char **names = NULL; _cleanup_free_ char *path = NULL; diff --git a/src/nspawn/test-nspawn-util.c b/src/nspawn/test-nspawn-util.c index ed68063630..08c8050dc5 100644 --- a/src/nspawn/test-nspawn-util.c +++ b/src/nspawn/test-nspawn-util.c @@ -16,4 +16,7 @@ TEST(systemd_installation_has_version) { } } +/* This program can be called with a path to an installation root. + * For example: build/test-nspawn-util /var/lib/machines/rawhide + */ DEFINE_TEST_MAIN(LOG_DEBUG); From c3eaba2d3d0d5c3efab9d9618a5e58d35ceaada3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 7 Apr 2022 13:43:18 +0200 Subject: [PATCH 6/9] Move path_simplify_and_warn() to new shared/parse-helpers.c This is a high-level function, and it belongs in libsystemd-shared. This way we don't end up linking a separate copy into various binaries. It would even end up in libsystemd, where it is not needed. (Maybe it'd be removed in some optimization phase, but it's better to not rely on that.) $ grep -l -r -a 'path is not absolute%s' build/ build/libnss_systemd.so.2 build/pam_systemd_home.so build/test-dlopen build/src/basic/libbasic.a.p/path-util.c.o build/src/basic/libbasic.a build/src/shared/libsystemd-shared-249.so build/test-bus-error build/libnss_mymachines.so.2 build/pam_systemd.so build/libnss_resolve.so.2 build/libnss_myhostname.so.2 build/libsystemd.so.0.32.0 build/libudev.so.1.7.2 $ grep -l -r -a 'path is not absolute%s' build/ build/src/shared/libsystemd-shared-251.a.p/parse-helpers.c.o build/src/shared/libsystemd-shared-251.a build/src/shared/libsystemd-shared-251.so No functional change. --- src/basic/path-util.c | 47 -------------------------- src/basic/path-util.h | 8 ----- src/core/load-fragment.c | 1 + src/journal-remote/journal-upload.c | 3 +- src/network/netdev/macsec.c | 2 +- src/network/netdev/wireguard.c | 2 +- src/partition/repart.c | 3 +- src/shared/conf-parser.c | 1 + src/shared/meson.build | 2 ++ src/shared/parse-helpers.c | 52 +++++++++++++++++++++++++++++ src/shared/parse-helpers.h | 16 +++++++++ src/sysupdate/sysupdate-transfer.c | 2 +- 12 files changed, 77 insertions(+), 62 deletions(-) create mode 100644 src/shared/parse-helpers.c create mode 100644 src/shared/parse-helpers.h diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 979c6f2c9d..94527eff4c 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -24,7 +24,6 @@ #include "string-util.h" #include "strv.h" #include "time-util.h" -#include "utf8.h" int path_split_and_make_absolute(const char *p, char ***ret) { char **l; @@ -373,52 +372,6 @@ char *path_simplify(char *path) { return path; } -int path_simplify_and_warn( - char *path, - unsigned flag, - const char *unit, - const char *filename, - unsigned line, - const char *lvalue) { - - bool fatal = flag & PATH_CHECK_FATAL; - - assert(!FLAGS_SET(flag, PATH_CHECK_ABSOLUTE | PATH_CHECK_RELATIVE)); - - if (!utf8_is_valid(path)) - return log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, path); - - if (flag & (PATH_CHECK_ABSOLUTE | PATH_CHECK_RELATIVE)) { - bool absolute; - - absolute = path_is_absolute(path); - - if (!absolute && (flag & PATH_CHECK_ABSOLUTE)) - return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), - "%s= path is not absolute%s: %s", - lvalue, fatal ? "" : ", ignoring", path); - - if (absolute && (flag & PATH_CHECK_RELATIVE)) - return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), - "%s= path is absolute%s: %s", - lvalue, fatal ? "" : ", ignoring", path); - } - - path_simplify(path); - - if (!path_is_valid(path)) - return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), - "%s= path has invalid length (%zu bytes)%s.", - lvalue, strlen(path), fatal ? "" : ", ignoring"); - - if (!path_is_normalized(path)) - return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), - "%s= path is not normalized%s: %s", - lvalue, fatal ? "" : ", ignoring", path); - - return 0; -} - char *path_startswith_full(const char *path, const char *prefix, bool accept_dot_dot) { assert(path); assert(prefix); diff --git a/src/basic/path-util.h b/src/basic/path-util.h index 2f55b3abb1..553aa4fb58 100644 --- a/src/basic/path-util.h +++ b/src/basic/path-util.h @@ -77,14 +77,6 @@ char* path_extend_internal(char **x, ...); char* path_simplify(char *path); -enum { - PATH_CHECK_FATAL = 1 << 0, /* If not set, then error message is appended with 'ignoring'. */ - PATH_CHECK_ABSOLUTE = 1 << 1, - PATH_CHECK_RELATIVE = 1 << 2, -}; - -int path_simplify_and_warn(char *path, unsigned flag, const char *unit, const char *filename, unsigned line, const char *lvalue); - static inline bool path_equal_ptr(const char *a, const char *b) { return !!a == !!b && (!a || path_equal(a, b)); } diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 66e0c01c23..b81db4617b 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -50,6 +50,7 @@ #include "mountpoint-util.h" #include "nulstr-util.h" #include "parse-socket-bind-item.h" +#include "parse-helpers.h" #include "parse-util.h" #include "path-util.h" #include "percent-util.h" diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c index db6cedfb16..2ad175c248 100644 --- a/src/journal-remote/journal-upload.c +++ b/src/journal-remote/journal-upload.c @@ -23,8 +23,7 @@ #include "main-func.h" #include "mkdir.h" #include "parse-argument.h" -#include "parse-util.h" -#include "path-util.h" +#include "parse-helpers.h" #include "pretty-print.h" #include "process-util.h" #include "rlimit-util.h" diff --git a/src/network/netdev/macsec.c b/src/network/netdev/macsec.c index ac626495bc..03ac92daaf 100644 --- a/src/network/netdev/macsec.c +++ b/src/network/netdev/macsec.c @@ -14,7 +14,7 @@ #include "memory-util.h" #include "netlink-util.h" #include "networkd-manager.h" -#include "path-util.h" +#include "parse-helpers.h" #include "socket-util.h" #include "string-table.h" #include "string-util.h" diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c index 32525e6200..fc2c6288ae 100644 --- a/src/network/netdev/wireguard.c +++ b/src/network/netdev/wireguard.c @@ -23,8 +23,8 @@ #include "networkd-route-util.h" #include "networkd-route.h" #include "networkd-util.h" +#include "parse-helpers.h" #include "parse-util.h" -#include "path-util.h" #include "random-util.h" #include "resolve-private.h" #include "string-util.h" diff --git a/src/partition/repart.c b/src/partition/repart.c index 118ab6c7d0..b6ac17c75e 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -46,8 +46,7 @@ #include "mount-util.h" #include "mountpoint-util.h" #include "parse-argument.h" -#include "parse-util.h" -#include "path-util.h" +#include "parse-helpers.h" #include "pretty-print.h" #include "proc-cmdline.h" #include "process-util.h" diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index aeea0a02d5..6c105e7fd2 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -24,6 +24,7 @@ #include "macro.h" #include "missing_network.h" #include "nulstr-util.h" +#include "parse-helpers.h" #include "parse-util.h" #include "path-util.h" #include "percent-util.h" diff --git a/src/shared/meson.build b/src/shared/meson.build index 4333c9a0a9..8f1f3b40a9 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -245,6 +245,8 @@ shared_sources = files( 'pager.h', 'parse-argument.c', 'parse-argument.h', + 'parse-helpers.c', + 'parse-helpers.h', 'parse-socket-bind-item.c', 'parse-socket-bind-item.h', 'pcre2-dlopen.c', diff --git a/src/shared/parse-helpers.c b/src/shared/parse-helpers.c new file mode 100644 index 0000000000..5ebe366265 --- /dev/null +++ b/src/shared/parse-helpers.c @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "log.h" +#include "parse-helpers.h" +#include "path-util.h" +#include "utf8.h" + +int path_simplify_and_warn( + char *path, + unsigned flag, + const char *unit, + const char *filename, + unsigned line, + const char *lvalue) { + + bool fatal = flag & PATH_CHECK_FATAL; + + assert(!FLAGS_SET(flag, PATH_CHECK_ABSOLUTE | PATH_CHECK_RELATIVE)); + + if (!utf8_is_valid(path)) + return log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, path); + + if (flag & (PATH_CHECK_ABSOLUTE | PATH_CHECK_RELATIVE)) { + bool absolute; + + absolute = path_is_absolute(path); + + if (!absolute && (flag & PATH_CHECK_ABSOLUTE)) + return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), + "%s= path is not absolute%s: %s", + lvalue, fatal ? "" : ", ignoring", path); + + if (absolute && (flag & PATH_CHECK_RELATIVE)) + return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), + "%s= path is absolute%s: %s", + lvalue, fatal ? "" : ", ignoring", path); + } + + path_simplify(path); + + if (!path_is_valid(path)) + return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), + "%s= path has invalid length (%zu bytes)%s.", + lvalue, strlen(path), fatal ? "" : ", ignoring"); + + if (!path_is_normalized(path)) + return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), + "%s= path is not normalized%s: %s", + lvalue, fatal ? "" : ", ignoring", path); + + return 0; +} diff --git a/src/shared/parse-helpers.h b/src/shared/parse-helpers.h new file mode 100644 index 0000000000..8b1d33498c --- /dev/null +++ b/src/shared/parse-helpers.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +enum { + PATH_CHECK_FATAL = 1 << 0, /* If not set, then error message is appended with 'ignoring'. */ + PATH_CHECK_ABSOLUTE = 1 << 1, + PATH_CHECK_RELATIVE = 1 << 2, +}; + +int path_simplify_and_warn( + char *path, + unsigned flag, + const char *unit, + const char *filename, + unsigned line, + const char *lvalue); diff --git a/src/sysupdate/sysupdate-transfer.c b/src/sysupdate/sysupdate-transfer.c index a9fceed601..e5bbbadc16 100644 --- a/src/sysupdate/sysupdate-transfer.c +++ b/src/sysupdate/sysupdate-transfer.c @@ -12,8 +12,8 @@ #include "gpt.h" #include "hexdecoct.h" #include "install-file.h" +#include "parse-helpers.h" #include "parse-util.h" -#include "path-util.h" #include "process-util.h" #include "rm-rf.h" #include "specifier.h" From 3fb72d6388c70def79b70b9f20c8e3c5c4609840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 7 Apr 2022 14:03:26 +0200 Subject: [PATCH 7/9] Merge parse-socket-bind-item.? into parse-helpers.? That file only exported one function, and it fits nicely within the scope of "parse helpers". Let's move it there to reduce the file count a bit. No functional change. --- src/core/load-fragment.c | 1 - src/shared/bus-unit-util.c | 2 +- src/shared/meson.build | 2 - src/shared/parse-helpers.c | 147 +++++++++++++++++ src/shared/parse-helpers.h | 9 ++ src/shared/parse-socket-bind-item.c | 150 ------------------ src/shared/parse-socket-bind-item.h | 12 -- src/test/meson.build | 2 +- ...ocket-bind-item.c => test-parse-helpers.c} | 2 +- 9 files changed, 159 insertions(+), 168 deletions(-) delete mode 100644 src/shared/parse-socket-bind-item.c delete mode 100644 src/shared/parse-socket-bind-item.h rename src/test/{test-parse-socket-bind-item.c => test-parse-helpers.c} (99%) diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index b81db4617b..74c41335ca 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -49,7 +49,6 @@ #include "missing_ioprio.h" #include "mountpoint-util.h" #include "nulstr-util.h" -#include "parse-socket-bind-item.h" #include "parse-helpers.h" #include "parse-util.h" #include "path-util.h" diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index 95ef3230b4..4f02c2c373 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -29,7 +29,7 @@ #include "mountpoint-util.h" #include "nsflags.h" #include "numa-util.h" -#include "parse-socket-bind-item.h" +#include "parse-helpers.h" #include "parse-util.h" #include "path-util.h" #include "percent-util.h" diff --git a/src/shared/meson.build b/src/shared/meson.build index 8f1f3b40a9..1d4e4a07c0 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -247,8 +247,6 @@ shared_sources = files( 'parse-argument.h', 'parse-helpers.c', 'parse-helpers.h', - 'parse-socket-bind-item.c', - 'parse-socket-bind-item.h', 'pcre2-dlopen.c', 'pcre2-dlopen.h', 'pe-header.h', diff --git a/src/shared/parse-helpers.c b/src/shared/parse-helpers.c index 5ebe366265..a9bb58715e 100644 --- a/src/shared/parse-helpers.c +++ b/src/shared/parse-helpers.c @@ -1,7 +1,11 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include "af-list.h" +#include "extract-word.h" +#include "ip-protocol-list.h" #include "log.h" #include "parse-helpers.h" +#include "parse-util.h" #include "path-util.h" #include "utf8.h" @@ -50,3 +54,146 @@ int path_simplify_and_warn( return 0; } + +static int parse_af_token( + const char *token, + int *family, + int *ip_protocol, + uint16_t *nr_ports, + uint16_t *port_min) { + + int af; + + assert(token); + assert(family); + + af = af_from_ipv4_ipv6(token); + if (af == AF_UNSPEC) + return -EINVAL; + + *family = af; + return 0; +} + +static int parse_ip_protocol_token( + const char *token, + int *family, + int *ip_protocol, + uint16_t *nr_ports, + uint16_t *port_min) { + + int proto; + + assert(token); + assert(ip_protocol); + + proto = ip_protocol_from_tcp_udp(token); + if (proto < 0) + return -EINVAL; + + *ip_protocol = proto; + return 0; +} + +static int parse_ip_ports_token( + const char *token, + int *family, + int *ip_protocol, + uint16_t *nr_ports, + uint16_t *port_min) { + + assert(token); + assert(nr_ports); + assert(port_min); + + if (streq(token, "any")) + *nr_ports = *port_min = 0; + else { + uint16_t mn = 0, mx = 0; + int r = parse_ip_port_range(token, &mn, &mx); + if (r < 0) + return r; + + *nr_ports = mx - mn + 1; + *port_min = mn; + } + + return 0; +} + +typedef int (*parse_token_f)( + const char *, + int *, + int *, + uint16_t *, + uint16_t *); + +int parse_socket_bind_item( + const char *str, + int *address_family, + int *ip_protocol, + uint16_t *nr_ports, + uint16_t *port_min) { + + /* Order of token parsers is important. */ + const parse_token_f parsers[] = { + &parse_af_token, + &parse_ip_protocol_token, + &parse_ip_ports_token, + }; + parse_token_f const *parser_ptr = parsers; + int af = AF_UNSPEC, proto = 0, r; + uint16_t nr = 0, mn = 0; + const char *p = str; + + assert(str); + assert(address_family); + assert(ip_protocol); + assert(nr_ports); + assert(port_min); + + if (isempty(p)) + return -EINVAL; + + for (;;) { + _cleanup_free_ char *token = NULL; + + r = extract_first_word(&p, &token, ":", EXTRACT_DONT_COALESCE_SEPARATORS); + if (r == 0) + break; + if (r < 0) + return r; + + if (isempty(token)) + return -EINVAL; + + while (parser_ptr != parsers + ELEMENTSOF(parsers)) { + r = (*parser_ptr)(token, &af, &proto, &nr, &mn); + if (r == -ENOMEM) + return r; + + ++parser_ptr; + /* Continue to next token if parsing succeeded, + * otherwise apply next parser to the same token. + */ + if (r >= 0) + break; + } + if (parser_ptr == parsers + ELEMENTSOF(parsers)) + break; + } + + /* Failed to parse a token. */ + if (r < 0) + return r; + + /* Parsers applied successfully, but end of the string not reached. */ + if (p) + return -EINVAL; + + *address_family = af; + *ip_protocol = proto; + *nr_ports = nr; + *port_min = mn; + return 0; +} diff --git a/src/shared/parse-helpers.h b/src/shared/parse-helpers.h index 8b1d33498c..49da2815fb 100644 --- a/src/shared/parse-helpers.h +++ b/src/shared/parse-helpers.h @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include + enum { PATH_CHECK_FATAL = 1 << 0, /* If not set, then error message is appended with 'ignoring'. */ PATH_CHECK_ABSOLUTE = 1 << 1, @@ -14,3 +16,10 @@ int path_simplify_and_warn( const char *filename, unsigned line, const char *lvalue); + +int parse_socket_bind_item( + const char *str, + int *address_family, + int *ip_protocol, + uint16_t *nr_ports, + uint16_t *port_min); diff --git a/src/shared/parse-socket-bind-item.c b/src/shared/parse-socket-bind-item.c deleted file mode 100644 index 3c92467632..0000000000 --- a/src/shared/parse-socket-bind-item.c +++ /dev/null @@ -1,150 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ - -#include "af-list.h" -#include "extract-word.h" -#include "ip-protocol-list.h" -#include "parse-socket-bind-item.h" -#include "parse-util.h" - -static int parse_af_token( - const char *token, - int *family, - int *ip_protocol, - uint16_t *nr_ports, - uint16_t *port_min) { - - int af; - - assert(token); - assert(family); - - af = af_from_ipv4_ipv6(token); - if (af == AF_UNSPEC) - return -EINVAL; - - *family = af; - return 0; -} - -static int parse_ip_protocol_token( - const char *token, - int *family, - int *ip_protocol, - uint16_t *nr_ports, - uint16_t *port_min) { - - int proto; - - assert(token); - assert(ip_protocol); - - proto = ip_protocol_from_tcp_udp(token); - if (proto < 0) - return -EINVAL; - - *ip_protocol = proto; - return 0; -} - -static int parse_ip_ports_token( - const char *token, - int *family, - int *ip_protocol, - uint16_t *nr_ports, - uint16_t *port_min) { - - assert(token); - assert(nr_ports); - assert(port_min); - - if (streq(token, "any")) - *nr_ports = *port_min = 0; - else { - uint16_t mn = 0, mx = 0; - int r = parse_ip_port_range(token, &mn, &mx); - if (r < 0) - return r; - - *nr_ports = mx - mn + 1; - *port_min = mn; - } - - return 0; -} - -typedef int (*parse_token_f)( - const char *, - int *, - int *, - uint16_t *, - uint16_t *); - -int parse_socket_bind_item( - const char *str, - int *address_family, - int *ip_protocol, - uint16_t *nr_ports, - uint16_t *port_min) { - - /* Order of token parsers is important. */ - const parse_token_f parsers[] = { - &parse_af_token, - &parse_ip_protocol_token, - &parse_ip_ports_token, - }; - parse_token_f const *parser_ptr = parsers; - int af = AF_UNSPEC, proto = 0, r; - uint16_t nr = 0, mn = 0; - const char *p = str; - - assert(str); - assert(address_family); - assert(ip_protocol); - assert(nr_ports); - assert(port_min); - - if (isempty(p)) - return -EINVAL; - - for (;;) { - _cleanup_free_ char *token = NULL; - - r = extract_first_word(&p, &token, ":", EXTRACT_DONT_COALESCE_SEPARATORS); - if (r == 0) - break; - if (r < 0) - return r; - - if (isempty(token)) - return -EINVAL; - - while (parser_ptr != parsers + ELEMENTSOF(parsers)) { - r = (*parser_ptr)(token, &af, &proto, &nr, &mn); - if (r == -ENOMEM) - return r; - - ++parser_ptr; - /* Continue to next token if parsing succeeded, - * otherwise apply next parser to the same token. - */ - if (r >= 0) - break; - } - if (parser_ptr == parsers + ELEMENTSOF(parsers)) - break; - } - - /* Failed to parse a token. */ - if (r < 0) - return r; - - /* Parsers applied successfully, but end of the string not reached. */ - if (p) - return -EINVAL; - - *address_family = af; - *ip_protocol = proto; - *nr_ports = nr; - *port_min = mn; - return 0; -} diff --git a/src/shared/parse-socket-bind-item.h b/src/shared/parse-socket-bind-item.h deleted file mode 100644 index c8cff8d730..0000000000 --- a/src/shared/parse-socket-bind-item.h +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ - -#pragma once - -#include - -int parse_socket_bind_item( - const char *str, - int *address_family, - int *ip_protocol, - uint16_t *nr_ports, - uint16_t *port_min); diff --git a/src/test/meson.build b/src/test/meson.build index 297a65d9af..c189f7073b 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -255,7 +255,7 @@ tests += [ [files('test-parse-argument.c')], - [files('test-parse-socket-bind-item.c')], + [files('test-parse-helpers.c')], [files('test-parse-util.c')], diff --git a/src/test/test-parse-socket-bind-item.c b/src/test/test-parse-helpers.c similarity index 99% rename from src/test/test-parse-socket-bind-item.c rename to src/test/test-parse-helpers.c index 6bca27265c..052e2514f4 100644 --- a/src/test/test-parse-socket-bind-item.c +++ b/src/test/test-parse-helpers.c @@ -5,7 +5,7 @@ #include #include "macro.h" -#include "parse-socket-bind-item.h" +#include "parse-helpers.h" #include "tests.h" static void test_valid_item( From a7fc59c70b4b99b64a1c7ac6cb4b5f7e85c8a133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 7 Apr 2022 14:51:55 +0200 Subject: [PATCH 8/9] various: add missing "#pragma once" --- src/basic/missing_syscall_def.h | 1 + src/basic/missing_syscalls.py | 1 + src/boot/efi/xbootldr.h | 1 + src/network/networkd-wiphy.h | 1 + 4 files changed, 4 insertions(+) diff --git a/src/basic/missing_syscall_def.h b/src/basic/missing_syscall_def.h index d078bf70df..88df92db61 100644 --- a/src/basic/missing_syscall_def.h +++ b/src/basic/missing_syscall_def.h @@ -4,6 +4,7 @@ * Use 'ninja -C build update-syscall-tables' to download new syscall tables, * and 'ninja -C build update-syscall-header' to regenerate this file. */ +#pragma once /* Note: if this code looks strange, this is because it is derived from the same * template as the per-syscall blocks below. */ diff --git a/src/basic/missing_syscalls.py b/src/basic/missing_syscalls.py index 2694e83b98..83199bb1d7 100644 --- a/src/basic/missing_syscalls.py +++ b/src/basic/missing_syscalls.py @@ -142,6 +142,7 @@ def print_syscall_defs(syscalls, tables, out): * Use 'ninja -C build update-syscall-tables' to download new syscall tables, * and 'ninja -C build update-syscall-header' to regenerate this file. */ +#pragma once ''', file=out) print(ARCH_CHECK, file=out) diff --git a/src/boot/efi/xbootldr.h b/src/boot/efi/xbootldr.h index 4cb370af29..205ce71edf 100644 --- a/src/boot/efi/xbootldr.h +++ b/src/boot/efi/xbootldr.h @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once #include diff --git a/src/network/networkd-wiphy.h b/src/network/networkd-wiphy.h index 072a7e5fdd..b40354704b 100644 --- a/src/network/networkd-wiphy.h +++ b/src/network/networkd-wiphy.h @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once #include From 6eb32c7f2e0a66154832dda2d5b9e8329eba9320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 7 Apr 2022 14:53:11 +0200 Subject: [PATCH 9/9] syscalls: update syscall definitions --- src/basic/syscall-list.txt | 1 + src/basic/syscalls-alpha.txt | 1 + src/basic/syscalls-arc.txt | 1 + src/basic/syscalls-arm.txt | 1 + src/basic/syscalls-arm64.txt | 1 + src/basic/syscalls-i386.txt | 1 + src/basic/syscalls-ia64.txt | 1 + src/basic/syscalls-loongarch64.txt | 1 + src/basic/syscalls-m68k.txt | 1 + src/basic/syscalls-mips64.txt | 1 + src/basic/syscalls-mips64n32.txt | 1 + src/basic/syscalls-mipso32.txt | 1 + src/basic/syscalls-powerpc.txt | 1 + src/basic/syscalls-powerpc64.txt | 1 + src/basic/syscalls-riscv32.txt | 1 + src/basic/syscalls-riscv64.txt | 1 + src/basic/syscalls-s390.txt | 1 + src/basic/syscalls-s390x.txt | 1 + src/basic/syscalls-sparc.txt | 1 + src/basic/syscalls-x86_64.txt | 1 + 20 files changed, 20 insertions(+) diff --git a/src/basic/syscall-list.txt b/src/basic/syscall-list.txt index 4e70907ade..fbc5566a65 100644 --- a/src/basic/syscall-list.txt +++ b/src/basic/syscall-list.txt @@ -473,6 +473,7 @@ sendmmsg sendmsg sendto set_mempolicy +set_mempolicy_home_node set_robust_list set_thread_area set_tid_address diff --git a/src/basic/syscalls-alpha.txt b/src/basic/syscalls-alpha.txt index 5aef86b09e..38988407fc 100644 --- a/src/basic/syscalls-alpha.txt +++ b/src/basic/syscalls-alpha.txt @@ -473,6 +473,7 @@ sendmmsg 503 sendmsg 114 sendto 133 set_mempolicy 431 +set_mempolicy_home_node 560 set_robust_list 466 set_thread_area set_tid_address 411 diff --git a/src/basic/syscalls-arc.txt b/src/basic/syscalls-arc.txt index f275f104bf..801f551c25 100644 --- a/src/basic/syscalls-arc.txt +++ b/src/basic/syscalls-arc.txt @@ -473,6 +473,7 @@ sendmmsg 269 sendmsg 211 sendto 206 set_mempolicy 237 +set_mempolicy_home_node 450 set_robust_list 99 set_thread_area set_tid_address 96 diff --git a/src/basic/syscalls-arm.txt b/src/basic/syscalls-arm.txt index 9037b28384..94bbcbf703 100644 --- a/src/basic/syscalls-arm.txt +++ b/src/basic/syscalls-arm.txt @@ -473,6 +473,7 @@ sendmmsg 374 sendmsg 296 sendto 290 set_mempolicy 321 +set_mempolicy_home_node 450 set_robust_list 338 set_thread_area set_tid_address 256 diff --git a/src/basic/syscalls-arm64.txt b/src/basic/syscalls-arm64.txt index e91d7cfca4..207c43937e 100644 --- a/src/basic/syscalls-arm64.txt +++ b/src/basic/syscalls-arm64.txt @@ -473,6 +473,7 @@ sendmmsg 269 sendmsg 211 sendto 206 set_mempolicy 237 +set_mempolicy_home_node 450 set_robust_list 99 set_thread_area set_tid_address 96 diff --git a/src/basic/syscalls-i386.txt b/src/basic/syscalls-i386.txt index 6b57d6f05d..4c0c99368e 100644 --- a/src/basic/syscalls-i386.txt +++ b/src/basic/syscalls-i386.txt @@ -473,6 +473,7 @@ sendmmsg 345 sendmsg 370 sendto 369 set_mempolicy 276 +set_mempolicy_home_node 450 set_robust_list 311 set_thread_area 243 set_tid_address 258 diff --git a/src/basic/syscalls-ia64.txt b/src/basic/syscalls-ia64.txt index 3d646f6d17..9346b2e0d1 100644 --- a/src/basic/syscalls-ia64.txt +++ b/src/basic/syscalls-ia64.txt @@ -473,6 +473,7 @@ sendmmsg 1331 sendmsg 1205 sendto 1199 set_mempolicy 1261 +set_mempolicy_home_node 1474 set_robust_list 1298 set_thread_area set_tid_address 1233 diff --git a/src/basic/syscalls-loongarch64.txt b/src/basic/syscalls-loongarch64.txt index 8b10af64db..848e9e90aa 100644 --- a/src/basic/syscalls-loongarch64.txt +++ b/src/basic/syscalls-loongarch64.txt @@ -473,6 +473,7 @@ sendmmsg 269 sendmsg 211 sendto 206 set_mempolicy 237 +set_mempolicy_home_node 450 set_robust_list 99 set_thread_area set_tid_address 96 diff --git a/src/basic/syscalls-m68k.txt b/src/basic/syscalls-m68k.txt index ef7295db2f..f5a95685f6 100644 --- a/src/basic/syscalls-m68k.txt +++ b/src/basic/syscalls-m68k.txt @@ -473,6 +473,7 @@ sendmmsg 372 sendmsg 367 sendto 366 set_mempolicy 270 +set_mempolicy_home_node 450 set_robust_list 304 set_thread_area 334 set_tid_address 253 diff --git a/src/basic/syscalls-mips64.txt b/src/basic/syscalls-mips64.txt index 1f7ff567be..7d0b9976b0 100644 --- a/src/basic/syscalls-mips64.txt +++ b/src/basic/syscalls-mips64.txt @@ -473,6 +473,7 @@ sendmmsg 5302 sendmsg 5045 sendto 5043 set_mempolicy 5229 +set_mempolicy_home_node 5450 set_robust_list 5268 set_thread_area 5242 set_tid_address 5212 diff --git a/src/basic/syscalls-mips64n32.txt b/src/basic/syscalls-mips64n32.txt index 7e1ad9637d..2e15c66124 100644 --- a/src/basic/syscalls-mips64n32.txt +++ b/src/basic/syscalls-mips64n32.txt @@ -473,6 +473,7 @@ sendmmsg 6307 sendmsg 6045 sendto 6043 set_mempolicy 6233 +set_mempolicy_home_node 6450 set_robust_list 6272 set_thread_area 6246 set_tid_address 6213 diff --git a/src/basic/syscalls-mipso32.txt b/src/basic/syscalls-mipso32.txt index c0c262fd1a..a8d95e3e35 100644 --- a/src/basic/syscalls-mipso32.txt +++ b/src/basic/syscalls-mipso32.txt @@ -473,6 +473,7 @@ sendmmsg 4343 sendmsg 4179 sendto 4180 set_mempolicy 4270 +set_mempolicy_home_node 4450 set_robust_list 4309 set_thread_area 4283 set_tid_address 4252 diff --git a/src/basic/syscalls-powerpc.txt b/src/basic/syscalls-powerpc.txt index 2f085161e1..ad68616e25 100644 --- a/src/basic/syscalls-powerpc.txt +++ b/src/basic/syscalls-powerpc.txt @@ -473,6 +473,7 @@ sendmmsg 349 sendmsg 341 sendto 335 set_mempolicy 261 +set_mempolicy_home_node 450 set_robust_list 300 set_thread_area set_tid_address 232 diff --git a/src/basic/syscalls-powerpc64.txt b/src/basic/syscalls-powerpc64.txt index 85e53422ee..9e8dc6dd8c 100644 --- a/src/basic/syscalls-powerpc64.txt +++ b/src/basic/syscalls-powerpc64.txt @@ -473,6 +473,7 @@ sendmmsg 349 sendmsg 341 sendto 335 set_mempolicy 261 +set_mempolicy_home_node 450 set_robust_list 300 set_thread_area set_tid_address 232 diff --git a/src/basic/syscalls-riscv32.txt b/src/basic/syscalls-riscv32.txt index 013e38189b..2a4aceff94 100644 --- a/src/basic/syscalls-riscv32.txt +++ b/src/basic/syscalls-riscv32.txt @@ -473,6 +473,7 @@ sendmmsg 269 sendmsg 211 sendto 206 set_mempolicy 237 +set_mempolicy_home_node 450 set_robust_list 99 set_thread_area set_tid_address 96 diff --git a/src/basic/syscalls-riscv64.txt b/src/basic/syscalls-riscv64.txt index 104a2d9dfa..07d1d4253a 100644 --- a/src/basic/syscalls-riscv64.txt +++ b/src/basic/syscalls-riscv64.txt @@ -473,6 +473,7 @@ sendmmsg 269 sendmsg 211 sendto 206 set_mempolicy 237 +set_mempolicy_home_node 450 set_robust_list 99 set_thread_area set_tid_address 96 diff --git a/src/basic/syscalls-s390.txt b/src/basic/syscalls-s390.txt index a25093c7be..bbc824c005 100644 --- a/src/basic/syscalls-s390.txt +++ b/src/basic/syscalls-s390.txt @@ -473,6 +473,7 @@ sendmmsg 358 sendmsg 370 sendto 369 set_mempolicy 270 +set_mempolicy_home_node 450 set_robust_list 304 set_thread_area set_tid_address 252 diff --git a/src/basic/syscalls-s390x.txt b/src/basic/syscalls-s390x.txt index b4b798f9df..bc385eabad 100644 --- a/src/basic/syscalls-s390x.txt +++ b/src/basic/syscalls-s390x.txt @@ -473,6 +473,7 @@ sendmmsg 358 sendmsg 370 sendto 369 set_mempolicy 270 +set_mempolicy_home_node 450 set_robust_list 304 set_thread_area set_tid_address 252 diff --git a/src/basic/syscalls-sparc.txt b/src/basic/syscalls-sparc.txt index a382e75c24..6c39ad86f4 100644 --- a/src/basic/syscalls-sparc.txt +++ b/src/basic/syscalls-sparc.txt @@ -473,6 +473,7 @@ sendmmsg 336 sendmsg 114 sendto 133 set_mempolicy 305 +set_mempolicy_home_node 450 set_robust_list 300 set_thread_area set_tid_address 166 diff --git a/src/basic/syscalls-x86_64.txt b/src/basic/syscalls-x86_64.txt index 5bc9c58a2a..2942c2e489 100644 --- a/src/basic/syscalls-x86_64.txt +++ b/src/basic/syscalls-x86_64.txt @@ -473,6 +473,7 @@ sendmmsg 307 sendmsg 46 sendto 44 set_mempolicy 238 +set_mempolicy_home_node 450 set_robust_list 273 set_thread_area 205 set_tid_address 218