diff --git a/parser/apparmor.systemd b/parser/apparmor.systemd index aa81ca8bb..09d579245 100644 --- a/parser/apparmor.systemd +++ b/parser/apparmor.systemd @@ -71,6 +71,13 @@ fi case "$1" in start) + if [ -x /usr/bin/systemd-detect-virt ] && \ + systemd-detect-virt --quiet --container && \ + ! is_container_with_internal_policy; then + aa_log_daemon_msg "Not starting AppArmor in container" + aa_log_end_msg 0 + exit 0 + fi apparmor_start rc=$? ;; @@ -79,6 +86,13 @@ case "$1" in rc=$? ;; restart|reload|force-reload) + if [ -x /usr/bin/systemd-detect-virt ] && \ + systemd-detect-virt --quiet --container && \ + ! is_container_with_internal_policy; then + aa_log_daemon_msg "Not starting AppArmor in container" + aa_log_end_msg 0 + exit 0 + fi apparmor_restart rc=$? ;;