Skip to content

Commit

Permalink
Remove check for apparmor_parser in apparmor.IsEnabled()
Browse files Browse the repository at this point in the history
The `apparmor_parser` binary is not really required for a system to run
AppArmor from a runc perspective. How to apply the profile is more in
the responsibility of higher level runtimes like Podman and Docker,
which may do the binary check on their own.

Signed-off-by: Sascha Grunert <[email protected]>
  • Loading branch information
saschagrunert committed Aug 20, 2020
1 parent e949339 commit bfb4ea1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions libcontainer/apparmor/apparmor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package apparmor

import (
"bytes"
"fmt"
"io/ioutil"
"os"
Expand All @@ -12,11 +13,9 @@ import (

// IsEnabled returns true if apparmor is enabled for the host.
func IsEnabled() bool {
if _, err := os.Stat("/sys/kernel/security/apparmor"); err == nil && os.Getenv("container") == "" {
if _, err = os.Stat("/sbin/apparmor_parser"); err == nil {
buf, err := ioutil.ReadFile("/sys/module/apparmor/parameters/enabled")
return err == nil && len(buf) > 1 && buf[0] == 'Y'
}
if _, err := os.Stat("/sys/kernel/security/apparmor"); err == nil {
buf, err := ioutil.ReadFile("/sys/module/apparmor/parameters/enabled")
return err == nil && bytes.HasPrefix(buf, []byte("Y"))
}
return false
}
Expand Down

0 comments on commit bfb4ea1

Please sign in to comment.