9c4570a9 |
// +build linux
|
4f0d95fa |
package daemon // import "github.com/docker/docker/daemon" |
9c4570a9 |
import ( |
567ef8e7 |
"fmt"
|
9c4570a9 |
aaprofile "github.com/docker/docker/profiles/apparmor"
"github.com/opencontainers/runc/libcontainer/apparmor"
)
// Define constants for native driver
const (
defaultApparmorProfile = "docker-default"
)
|
567ef8e7 |
func ensureDefaultAppArmorProfile() error { |
9c4570a9 |
if apparmor.IsEnabled() { |
567ef8e7 |
loaded, err := aaprofile.IsLoaded(defaultApparmorProfile)
if err != nil {
return fmt.Errorf("Could not check if %s AppArmor profile was loaded: %s", defaultApparmorProfile, err)
}
// Nothing to do.
if loaded {
return nil
}
// Load the profile. |
9c4570a9 |
if err := aaprofile.InstallDefault(defaultApparmorProfile); err != nil { |
dd340c52 |
return fmt.Errorf("AppArmor enabled on system but the %s profile could not be loaded: %s", defaultApparmorProfile, err) |
9c4570a9 |
}
} |
567ef8e7 |
return nil |
9c4570a9 |
} |