Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -58,6 +58,12 @@ const ( |
| 58 | 58 |
LinuxV1RuntimeName = "io.containerd.runtime.v1.linux" |
| 59 | 59 |
// LinuxV2RuntimeName is the runtime used to specify the containerd v2 runc shim |
| 60 | 60 |
LinuxV2RuntimeName = "io.containerd.runc.v2" |
| 61 |
+ |
|
| 62 |
+ // SeccompProfileDefault is the built-in default seccomp profile. |
|
| 63 |
+ SeccompProfileDefault = "default" |
|
| 64 |
+ // SeccompProfileUnconfined is a special profile name for seccomp to use an |
|
| 65 |
+ // "unconfined" seccomp profile. |
|
| 66 |
+ SeccompProfileUnconfined = "unconfined" |
|
| 61 | 67 |
) |
| 62 | 68 |
|
| 63 | 69 |
var builtinRuntimes = map[string]bool{
|
| ... | ... |
@@ -174,7 +174,7 @@ func (daemon *Daemon) fillSecurityOptions(v *types.Info, sysInfo *sysinfo.SysInf |
| 174 | 174 |
if sysInfo.Seccomp && supportsSeccomp {
|
| 175 | 175 |
profile := daemon.seccompProfilePath |
| 176 | 176 |
if profile == "" {
|
| 177 |
- profile = "default" |
|
| 177 |
+ profile = config.SeccompProfileDefault |
|
| 178 | 178 |
} |
| 179 | 179 |
securityOptions = append(securityOptions, fmt.Sprintf("name=seccomp,profile=%s", profile))
|
| 180 | 180 |
} |
| ... | ... |
@@ -9,6 +9,7 @@ import ( |
| 9 | 9 |
"github.com/containerd/containerd/containers" |
| 10 | 10 |
coci "github.com/containerd/containerd/oci" |
| 11 | 11 |
"github.com/docker/docker/container" |
| 12 |
+ dconfig "github.com/docker/docker/daemon/config" |
|
| 12 | 13 |
) |
| 13 | 14 |
|
| 14 | 15 |
const supportsSeccomp = false |
| ... | ... |
@@ -16,7 +17,7 @@ const supportsSeccomp = false |
| 16 | 16 |
// WithSeccomp sets the seccomp profile |
| 17 | 17 |
func WithSeccomp(daemon *Daemon, c *container.Container) coci.SpecOpts {
|
| 18 | 18 |
return func(ctx context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) error {
|
| 19 |
- if c.SeccompProfile != "" && c.SeccompProfile != "unconfined" {
|
|
| 19 |
+ if c.SeccompProfile != "" && c.SeccompProfile != dconfig.SeccompProfileUnconfined {
|
|
| 20 | 20 |
return fmt.Errorf("seccomp profiles are not supported on this daemon, you cannot specify a custom seccomp profile")
|
| 21 | 21 |
} |
| 22 | 22 |
return nil |
| ... | ... |
@@ -9,6 +9,7 @@ import ( |
| 9 | 9 |
"github.com/containerd/containerd/containers" |
| 10 | 10 |
coci "github.com/containerd/containerd/oci" |
| 11 | 11 |
"github.com/docker/docker/container" |
| 12 |
+ dconfig "github.com/docker/docker/daemon/config" |
|
| 12 | 13 |
"github.com/docker/docker/profiles/seccomp" |
| 13 | 14 |
"github.com/sirupsen/logrus" |
| 14 | 15 |
) |
| ... | ... |
@@ -18,7 +19,7 @@ const supportsSeccomp = true |
| 18 | 18 |
// WithSeccomp sets the seccomp profile |
| 19 | 19 |
func WithSeccomp(daemon *Daemon, c *container.Container) coci.SpecOpts {
|
| 20 | 20 |
return func(ctx context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) error {
|
| 21 |
- if c.SeccompProfile == "unconfined" {
|
|
| 21 |
+ if c.SeccompProfile == dconfig.SeccompProfileUnconfined {
|
|
| 22 | 22 |
return nil |
| 23 | 23 |
} |
| 24 | 24 |
if c.HostConfig.Privileged {
|
| ... | ... |
@@ -29,7 +30,7 @@ func WithSeccomp(daemon *Daemon, c *container.Container) coci.SpecOpts {
|
| 29 | 29 |
return fmt.Errorf("seccomp is not enabled in your kernel, cannot run a custom seccomp profile")
|
| 30 | 30 |
} |
| 31 | 31 |
logrus.Warn("seccomp is not enabled in your kernel, running container without default profile")
|
| 32 |
- c.SeccompProfile = "unconfined" |
|
| 32 |
+ c.SeccompProfile = dconfig.SeccompProfileUnconfined |
|
| 33 | 33 |
return nil |
| 34 | 34 |
} |
| 35 | 35 |
var err error |
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
coci "github.com/containerd/containerd/oci" |
| 9 | 9 |
config "github.com/docker/docker/api/types/container" |
| 10 | 10 |
"github.com/docker/docker/container" |
| 11 |
+ dconfig "github.com/docker/docker/daemon/config" |
|
| 11 | 12 |
doci "github.com/docker/docker/oci" |
| 12 | 13 |
"github.com/docker/docker/profiles/seccomp" |
| 13 | 14 |
specs "github.com/opencontainers/runtime-spec/specs-go" |
| ... | ... |
@@ -32,7 +33,7 @@ func TestWithSeccomp(t *testing.T) {
|
| 32 | 32 |
seccompEnabled: true, |
| 33 | 33 |
}, |
| 34 | 34 |
c: &container.Container{
|
| 35 |
- SeccompProfile: "unconfined", |
|
| 35 |
+ SeccompProfile: dconfig.SeccompProfileUnconfined, |
|
| 36 | 36 |
HostConfig: &config.HostConfig{
|
| 37 | 37 |
Privileged: false, |
| 38 | 38 |
}, |
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
"testing" |
| 8 | 8 |
|
| 9 | 9 |
"github.com/docker/docker/client" |
| 10 |
+ "github.com/docker/docker/daemon/config" |
|
| 10 | 11 |
"gotest.tools/v3/assert" |
| 11 | 12 |
is "gotest.tools/v3/assert/cmp" |
| 12 | 13 |
) |
| ... | ... |
@@ -27,6 +28,6 @@ func (s *DockerSuite) TestInfoSecurityOptions(c *testing.T) {
|
| 27 | 27 |
assert.Check(c, is.Contains(info.SecurityOptions, "name=apparmor")) |
| 28 | 28 |
} |
| 29 | 29 |
if seccompEnabled() {
|
| 30 |
- assert.Check(c, is.Contains(info.SecurityOptions, "name=seccomp,profile=default")) |
|
| 30 |
+ assert.Check(c, is.Contains(info.SecurityOptions, "name=seccomp,profile="+config.SeccompProfileDefault)) |
|
| 31 | 31 |
} |
| 32 | 32 |
} |