summaryrefslogtreecommitdiff
path: root/src/nspawn/test-nspawn-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-04-07 12:15:04 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-04-07 18:19:03 +0200
commit7e6821ed4e09d68c45858ba463a013eb7593c2c6 (patch)
tree77ccd8f447e80a29414a7d85a6b1e5ef4c41b945 /src/nspawn/test-nspawn-util.c
parentc9394f4f93b9a6baa54f9d1c953035f26dcee253 (diff)
downloadsystemd-7e6821ed4e09d68c45858ba463a013eb7593c2c6.tar.gz
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.
Diffstat (limited to 'src/nspawn/test-nspawn-util.c')
-rw-r--r--src/nspawn/test-nspawn-util.c10
1 files changed, 5 insertions, 5 deletions
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));
}
}