apparmor_default.go 824 B

123456789101112131415161718192021222324252627282930
  1. // +build linux
  2. package daemon
  3. import (
  4. "github.com/Sirupsen/logrus"
  5. aaprofile "github.com/docker/docker/profiles/apparmor"
  6. "github.com/opencontainers/runc/libcontainer/apparmor"
  7. )
  8. // Define constants for native driver
  9. const (
  10. defaultApparmorProfile = "docker-default"
  11. )
  12. func installDefaultAppArmorProfile() {
  13. if apparmor.IsEnabled() {
  14. if err := aaprofile.InstallDefault(defaultApparmorProfile); err != nil {
  15. apparmorProfiles := []string{defaultApparmorProfile}
  16. // Allow daemon to run if loading failed, but are active
  17. // (possibly through another run, manually, or via system startup)
  18. for _, policy := range apparmorProfiles {
  19. if err := aaprofile.IsLoaded(policy); err != nil {
  20. logrus.Errorf("AppArmor enabled on system but the %s profile could not be loaded.", policy)
  21. }
  22. }
  23. }
  24. }
  25. }