Skip to content

Commit

Permalink
virt: fix container detection
Browse files Browse the repository at this point in the history
Commit 1b86c7c ("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: 1b86c7c.
  • Loading branch information
bentiss authored and poettering committed Jan 5, 2023
1 parent 8109b29 commit a91078b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/basic/virt.c
Expand Up @@ -778,7 +778,7 @@ Virtualization detect_container(void) {
/* Some images hardcode container=oci, but OCI is not a specific container manager.
* Try to detect one based on well-known files. */
v = detect_container_files();
if (v != VIRTUALIZATION_NONE)
if (v == VIRTUALIZATION_NONE)
v = VIRTUALIZATION_CONTAINER_OTHER;
goto finish;
}
Expand Down

0 comments on commit a91078b

Please sign in to comment.