Skip to content

Commit ac817ce

Browse files
Add seccomp support.
1 parent 2638360 commit ac817ce

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

containerd/containerd.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
"github.com/containerd/containerd"
2626
"github.com/containerd/containerd/cio"
27+
"github.com/containerd/containerd/contrib/seccomp"
2728
"github.com/containerd/containerd/oci"
2829
specs "github.com/opencontainers/runtime-spec/specs-go"
2930
)
@@ -65,6 +66,12 @@ func (d *Driver) createContainer(image containerd.Image, containerName, containe
6566
opts = append(opts, oci.WithPrivileged)
6667
}
6768

69+
// Enable default seccomp profile.
70+
// Allowed syscalls for the default seccomp profile: https://github.com/containerd/containerd/blob/master/contrib/seccomp/seccomp_default.go#L51-L390
71+
if config.Seccomp {
72+
opts = append(opts, seccomp.WithDefaultProfile())
73+
}
74+
6875
// Launch container in read-only mode.
6976
if config.ReadOnlyRootfs {
7077
opts = append(opts, oci.WithRootFSReadonly())

containerd/driver.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ var (
9292
"cap_drop": hclspec.NewAttr("cap_drop", "list(string)", false),
9393
"devices": hclspec.NewAttr("devices", "list(string)", false),
9494
"privileged": hclspec.NewAttr("privileged", "bool", false),
95+
"seccomp": hclspec.NewAttr("seccomp", "bool", false),
9596
"readonly_rootfs": hclspec.NewAttr("readonly_rootfs", "bool", false),
9697
"host_network": hclspec.NewAttr("host_network", "bool", false),
9798
"mounts": hclspec.NewBlockList("mounts", hclspec.NewObject(map[string]*hclspec.Spec{
@@ -140,6 +141,7 @@ type TaskConfig struct {
140141
CapAdd []string `codec:"cap_add"`
141142
CapDrop []string `codec:"cap_drop"`
142143
Devices []string `codec:"devices"`
144+
Seccomp bool `codec:"seccomp"`
143145
Privileged bool `codec:"privileged"`
144146
ReadOnlyRootfs bool `codec:"readonly_rootfs"`
145147
HostNetwork bool `codec:"host_network"`

0 commit comments

Comments
 (0)