Skip to content

Commit c49fd13

Browse files
Add support for custom seccomp profiles.
1 parent fa7c293 commit c49fd13

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

containerd/containerd.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,18 @@ func (d *Driver) createContainer(image containerd.Image, containerName, containe
6666
opts = append(opts, oci.WithPrivileged)
6767
}
6868

69-
// Enable default seccomp profile.
69+
if !config.Seccomp && config.SeccompProfile != "" {
70+
return nil, fmt.Errorf("seccomp must be set to true, if using a custom seccomp_profile.")
71+
}
72+
73+
// Enable default (or custom) seccomp profile.
7074
// Allowed syscalls for the default seccomp profile: https://github.com/containerd/containerd/blob/master/contrib/seccomp/seccomp_default.go#L51-L390
7175
if config.Seccomp {
72-
opts = append(opts, seccomp.WithDefaultProfile())
76+
if config.SeccompProfile != "" {
77+
opts = append(opts, seccomp.WithProfile(config.SeccompProfile))
78+
} else {
79+
opts = append(opts, seccomp.WithDefaultProfile())
80+
}
7381
}
7482

7583
// Launch container in read-only mode.

containerd/driver.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ var (
9393
"devices": hclspec.NewAttr("devices", "list(string)", false),
9494
"privileged": hclspec.NewAttr("privileged", "bool", false),
9595
"seccomp": hclspec.NewAttr("seccomp", "bool", false),
96+
"seccomp_profile": hclspec.NewAttr("seccomp_profile", "string", false),
9697
"readonly_rootfs": hclspec.NewAttr("readonly_rootfs", "bool", false),
9798
"host_network": hclspec.NewAttr("host_network", "bool", false),
9899
"mounts": hclspec.NewBlockList("mounts", hclspec.NewObject(map[string]*hclspec.Spec{
@@ -143,6 +144,7 @@ type TaskConfig struct {
143144
CapDrop []string `codec:"cap_drop"`
144145
Devices []string `codec:"devices"`
145146
Seccomp bool `codec:"seccomp"`
147+
SeccompProfile string `codec:"seccomp_profile"`
146148
Privileged bool `codec:"privileged"`
147149
ReadOnlyRootfs bool `codec:"readonly_rootfs"`
148150
HostNetwork bool `codec:"host_network"`

0 commit comments

Comments
 (0)