Add DefaultContent API to retrieve apparmor profile content

The default apparmor profile is not stored on disk which causes
confusion when debugging the content of the profile. To solve this, we
now add an additional API which returns the profile as byte slice.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
This commit is contained in:
Sascha Grunert
2019-07-18 10:01:45 +02:00
parent 7488ed6d9a
commit 27ebd7d6f0
3 changed files with 32 additions and 3 deletions

View File

@ -78,10 +78,12 @@ Copyright 2009-2012 Canonical Ltd.
}
}
func TestInstallDefault(t *testing.T) {
profile := "libpod-default-testing"
aapath := "/sys/kernel/security/apparmor/"
const (
aapath = "/sys/kernel/security/apparmor/"
profile = "libpod-default-testing"
)
func TestInstallDefault(t *testing.T) {
if _, err := os.Stat(aapath); err != nil {
t.Skip("AppArmor isn't available in this environment")
}
@ -127,3 +129,12 @@ func TestInstallDefault(t *testing.T) {
}
checkLoaded(false)
}
func TestDefaultContent(t *testing.T) {
if _, err := os.Stat(aapath); err != nil {
t.Skip("AppArmor isn't available in this environment")
}
if err := DefaultContent(profile); err != nil {
t.Fatalf("Couldn't retrieve default AppArmor profile content '%s': %v", profile, err)
}
}