mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
daemon: allow "builtin" as valid value for seccomp profiles
This allows containers to use the embedded default profile if a different default is set (e.g. "unconfined") in the daemon configuration. Without this option, users would have to copy the default profile to a file in order to use the default. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
68e96f88ee
commit
f8795ed364
3 changed files with 9 additions and 2 deletions
|
@ -1706,7 +1706,7 @@ func maybeCreateCPURealTimeFile(configValue int64, file string, path string) err
|
|||
}
|
||||
|
||||
func (daemon *Daemon) setupSeccompProfile() error {
|
||||
if daemon.configStore.SeccompProfile != "" {
|
||||
if daemon.configStore.SeccompProfile != "" && daemon.configStore.SeccompProfile != config.SeccompProfileDefault {
|
||||
daemon.seccompProfilePath = daemon.configStore.SeccompProfile
|
||||
if daemon.configStore.SeccompProfile != config.SeccompProfileUnconfined {
|
||||
b, err := ioutil.ReadFile(daemon.configStore.SeccompProfile)
|
||||
|
|
|
@ -26,7 +26,7 @@ func WithSeccomp(daemon *Daemon, c *container.Container) coci.SpecOpts {
|
|||
return nil
|
||||
}
|
||||
if !daemon.seccompEnabled {
|
||||
if c.SeccompProfile != "" {
|
||||
if c.SeccompProfile != "" && c.SeccompProfile != dconfig.SeccompProfileDefault {
|
||||
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")
|
||||
|
@ -35,6 +35,8 @@ func WithSeccomp(daemon *Daemon, c *container.Container) coci.SpecOpts {
|
|||
}
|
||||
var err error
|
||||
switch {
|
||||
case c.SeccompProfile == dconfig.SeccompProfileDefault:
|
||||
s.Linux.Seccomp, err = seccomp.GetDefaultProfile(s)
|
||||
case c.SeccompProfile != "":
|
||||
s.Linux.Seccomp, err = seccomp.LoadProfile(c.SeccompProfile, s)
|
||||
case daemon.seccompProfile != nil:
|
||||
|
|
|
@ -116,6 +116,11 @@ func TestConfigDaemonSeccompProfiles(t *testing.T) {
|
|||
profile: "",
|
||||
expectedProfile: config.SeccompProfileDefault,
|
||||
},
|
||||
{
|
||||
doc: "default profile",
|
||||
profile: config.SeccompProfileDefault,
|
||||
expectedProfile: config.SeccompProfileDefault,
|
||||
},
|
||||
{
|
||||
doc: "unconfined profile",
|
||||
profile: config.SeccompProfileUnconfined,
|
||||
|
|
Loading…
Reference in a new issue