Merge pull request #4709 from AkihiroSuda/ctr-apparmor
ctr: add AppArmor flags
This commit is contained in:
commit
5f74840a9a
@ -163,6 +163,14 @@ var (
|
|||||||
Name: "seccomp-profile",
|
Name: "seccomp-profile",
|
||||||
Usage: "file path to custom seccomp profile. seccomp must be set to true, before using seccomp-profile",
|
Usage: "file path to custom seccomp profile. seccomp must be set to true, before using seccomp-profile",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "apparmor-default-profile",
|
||||||
|
Usage: "enable AppArmor with the default profile with the specified name, e.g. \"cri-containerd.apparmor.d\"",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "apparmor-profile",
|
||||||
|
Usage: "enable AppArmor with an existing custom profile",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import (
|
|||||||
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||||
|
"github.com/containerd/containerd/contrib/apparmor"
|
||||||
"github.com/containerd/containerd/contrib/nvidia"
|
"github.com/containerd/containerd/contrib/nvidia"
|
||||||
"github.com/containerd/containerd/contrib/seccomp"
|
"github.com/containerd/containerd/contrib/seccomp"
|
||||||
"github.com/containerd/containerd/oci"
|
"github.com/containerd/containerd/oci"
|
||||||
@ -206,6 +207,17 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s := context.String("apparmor-default-profile"); len(s) > 0 {
|
||||||
|
opts = append(opts, apparmor.WithDefaultProfile(s))
|
||||||
|
}
|
||||||
|
|
||||||
|
if s := context.String("apparmor-profile"); len(s) > 0 {
|
||||||
|
if len(context.String("apparmor-default-profile")) > 0 {
|
||||||
|
return nil, fmt.Errorf("apparmor-profile conflicts with apparmor-default-profile")
|
||||||
|
}
|
||||||
|
opts = append(opts, apparmor.WithProfile(s))
|
||||||
|
}
|
||||||
|
|
||||||
if cpus := context.Float64("cpus"); cpus > 0.0 {
|
if cpus := context.Float64("cpus"); cpus > 0.0 {
|
||||||
var (
|
var (
|
||||||
period = uint64(100000)
|
period = uint64(100000)
|
||||||
|
Loading…
Reference in New Issue
Block a user