9c4570a9 |
// +build linux,seccomp
package daemon
import (
"fmt"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/container" |
99b16b35 |
"github.com/docker/docker/profiles/seccomp" |
041e5a21 |
"github.com/opencontainers/runtime-spec/specs-go" |
9c4570a9 |
)
|
a3b9dd89 |
var supportsSeccomp = true
|
9c4570a9 |
func setSeccomp(daemon *Daemon, rs *specs.Spec, c *container.Container) error { |
99b16b35 |
var profile *specs.Seccomp |
9c4570a9 |
var err error
if c.HostConfig.Privileged {
return nil
}
if !daemon.seccompEnabled {
if c.SeccompProfile != "" && c.SeccompProfile != "unconfined" {
return fmt.Errorf("Seccomp is not enabled in your kernel, cannot run a custom seccomp profile.")
}
logrus.Warn("Seccomp is not enabled in your kernel, running container without default profile.")
c.SeccompProfile = "unconfined"
}
if c.SeccompProfile == "unconfined" {
return nil
}
if c.SeccompProfile != "" { |
5ff21add |
profile, err = seccomp.LoadProfile(c.SeccompProfile, rs) |
9c4570a9 |
if err != nil {
return err
}
} else { |
b237189e |
if daemon.seccompProfile != nil {
profile, err = seccomp.LoadProfile(string(daemon.seccompProfile), rs)
if err != nil {
return err
}
} else {
profile, err = seccomp.GetDefaultProfile(rs)
if err != nil {
return err
} |
9c4570a9 |
}
}
|
99b16b35 |
rs.Linux.Seccomp = profile
return nil |
9c4570a9 |
} |