//go:build !windows
package daemon
import (
"github.com/moby/moby/v2/daemon/container"
"github.com/moby/moby/v2/errdefs"
)
func (daemon *Daemon) saveAppArmorConfig(container *container.Container) error {
container.AppArmorProfile = "" // reset; parseSecurityOpt re-derives it from HostConfig.SecurityOpt.
sysInfo, err := daemon.RawSysInfo()
if err != nil {
return errdefs.System(err)
}
if !sysInfo.AppArmor {
return nil // if apparmor is disabled there is nothing to do here.
}
if err := parseSecurityOpt(&container.SecurityOptions, container.HostConfig); err != nil {
return errdefs.InvalidParameter(err)
}
if container.AppArmorProfile == "" {
if container.HostConfig.Privileged {
container.AppArmorProfile = unconfinedAppArmorProfile
} else {
container.AppArmorProfile = defaultAppArmorProfile
}
}
return nil
}