]> git.ipfire.org Git - thirdparty/systemd.git/commit
nspawn: fix comparisons of versions with non-numerical suffixes
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 7 Apr 2022 10:15:04 +0000 (12:15 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 7 Apr 2022 16:19:03 +0000 (18:19 +0200)
commit7e6821ed4e09d68c45858ba463a013eb7593c2c6
tree77ccd8f447e80a29414a7d85a6b1e5ef4c41b945
parentc9394f4f93b9a6baa54f9d1c953035f26dcee253
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
src/nspawn/nspawn-util.h
src/nspawn/nspawn.c
src/nspawn/test-nspawn-util.c