mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 10:07:12 +00:00
Merge Enable AppArmor to run properly under WSL/systemd
The AppArmor systemd scripts correctly detect the Windows Subsystem for Linux as a container, since all Linux distros executing under WSL 2 are containerized; however, unlike the majority of containers (since there is no accessible host distribution above them trying to set AppArmor policies that might interfere), AppArmor itself functions without problems in the WSL environment. This patch adds WSL detection to the is_container_with_internal_policy function, allowing AppArmor to be started and operate normally in a WSL-plus-systemd environment. MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/812 Acked-by: John Johansen <john@jjmx.net>
This commit is contained in:
commit
72c06c4d35
@ -68,7 +68,7 @@ is_apparmor_present() {
|
||||
# something like `systemd-detect-virt --container`.
|
||||
#
|
||||
# The only known container environments capable of supporting internal policy
|
||||
# are LXD and LXC environment.
|
||||
# are LXD and LXC environments, and Windows Subsystem for Linux.
|
||||
#
|
||||
# Returns 0 if the container environment is capable of having its own internal
|
||||
# policy and non-zero otherwise.
|
||||
@ -90,6 +90,11 @@ is_container_with_internal_policy() {
|
||||
local ns_stacked
|
||||
local ns_name
|
||||
|
||||
# WSL needs to be detected explicitly
|
||||
if [ $(systemd-detect-virt --container) = "wsl" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if ! [ -f "$ns_stacked_path" ] || ! [ -f "$ns_name_path" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user