]> git.ipfire.org Git - thirdparty/systemd.git/commit
virt: fix container detection
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Thu, 5 Jan 2023 12:57:51 +0000 (13:57 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 5 Jan 2023 20:45:53 +0000 (21:45 +0100)
commita91078bc57950c9b0c19fd25fb2e802409695304
tree0111ea1ed0588e7f5d6625edae19e294fc305ba5
parent8109b2908def1b8038e0a6d3474eeca7cd143d4f
virt: fix container detection

Commit 1b86c7c59ecc ("virt: make virtualization enum a named type")
made the conversion from `if (!r)` to `if (v != VIRTUALIZATION_NONE)`.

However, the initial test was meaning "if r is null", IOW "if r IS
`VIRTUALIZATION_NONE`).

The test is wrong and this can lead to false detection of the container
environment (when calling `systemctl exit`).

For example, https://gitlab.freedesktop.org/whot/libevdev/-/jobs/34207974
is calling `systemctl exit 0`, and systemd terminates with the exit code
`130`.

Fixing that typo makes `systemctl exit 0` returns `0`.

Fixes: 1b86c7c59ecc26efdf278f5c1c4430346021cd38.
src/basic/virt.c