mirror of
https://github.com/moby/moby.git
synced 2026-06-30 19:58:03 +00:00
34 lines
850 B
Go
34 lines
850 B
Go
//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
|
|
}
|