rc.apparmor.functions: only use systemd-detect-virt if it's present

This is a follow-up on !812, which added a call to systemd-detect-virt.
Everywhere else we don't assume that program is present,
and first check if it's there before we run it.
Let's do the same here.
This commit is contained in:
intrigeri 2022-07-06 06:41:35 +00:00
parent 57eebd6cdb
commit 06f86e2a02

View file

@ -91,7 +91,8 @@ is_container_with_internal_policy() {
local ns_name
# WSL needs to be detected explicitly
if [ "$(systemd-detect-virt --container)" = "wsl" ]; then
if [ -x /usr/bin/systemd-detect-virt ] && \
[ "$(systemd-detect-virt --container)" = "wsl" ]; then
return 0
fi