Skip to content

Commit 779701b

Browse files
committed
Add --seccomp flag to ctr
This enables testing of containers with the default seccomp profile Signed-off-by: Michael Crosby <[email protected]>
1 parent 86f8be8 commit 779701b

4 files changed

Lines changed: 34 additions & 2 deletions

File tree

cmd/ctr/commands/commands.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ var (
130130
Name: "device",
131131
Usage: "add a device to a container",
132132
},
133+
cli.BoolFlag{
134+
Name: "seccomp",
135+
Usage: "enable the default seccomp profile",
136+
},
133137
}
134138
)
135139

cmd/ctr/commands/run/run_unix.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/containerd/containerd"
2727
"github.com/containerd/containerd/cmd/ctr/commands"
2828
"github.com/containerd/containerd/contrib/nvidia"
29+
"github.com/containerd/containerd/contrib/seccomp"
2930
"github.com/containerd/containerd/oci"
3031
"github.com/containerd/containerd/platforms"
3132
"github.com/opencontainers/runtime-spec/specs-go"
@@ -126,6 +127,9 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
126127
if context.Bool("net-host") {
127128
opts = append(opts, oci.WithHostNamespace(specs.NetworkNamespace), oci.WithHostHostsFile, oci.WithHostResolvconf)
128129
}
130+
if context.Bool("seccomp") {
131+
opts = append(opts, seccomp.WithDefaultProfile())
132+
}
129133

130134
joinNs := context.StringSlice("with-ns")
131135
for _, ns := range joinNs {

contrib/seccomp/seccomp.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// +build linux
2-
31
/*
42
Copyright The containerd Authors.
53
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// +build !linux
2+
3+
/*
4+
Copyright The containerd Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package seccomp
20+
21+
import specs "github.com/opencontainers/runtime-spec/specs-go"
22+
23+
// DefaultProfile defines the whitelist for the default seccomp profile.
24+
func DefaultProfile(sp *specs.Spec) *specs.LinuxSeccomp {
25+
return &specs.LinuxSeccomp{}
26+
}

0 commit comments

Comments
 (0)