Merge pull request #6289 from ManaSugi/add-ctr-caps
ctr: Add Linux Capabilities control flags
This commit is contained in:
commit
0d720ff9c9
@ -169,6 +169,14 @@ var (
|
|||||||
Name: "device",
|
Name: "device",
|
||||||
Usage: "file path to a device to add to the container; or a path to a directory tree of devices to add to the container",
|
Usage: "file path to a device to add to the container; or a path to a directory tree of devices to add to the container",
|
||||||
},
|
},
|
||||||
|
cli.StringSliceFlag{
|
||||||
|
Name: "cap-add",
|
||||||
|
Usage: "add Linux capabilities (Set capabilities with 'CAP_' prefix)",
|
||||||
|
},
|
||||||
|
cli.StringSliceFlag{
|
||||||
|
Name: "cap-drop",
|
||||||
|
Usage: "drop Linux capabilities (Set capabilities with 'CAP_' prefix)",
|
||||||
|
},
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "seccomp",
|
Name: "seccomp",
|
||||||
Usage: "enable the default seccomp profile",
|
Usage: "enable the default seccomp profile",
|
||||||
|
@ -218,6 +218,24 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if caps := context.StringSlice("cap-add"); len(caps) > 0 {
|
||||||
|
for _, cap := range caps {
|
||||||
|
if !strings.HasPrefix(cap, "CAP_") {
|
||||||
|
return nil, fmt.Errorf("capabilities must be specified with 'CAP_' prefix")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
opts = append(opts, oci.WithAddedCapabilities(caps))
|
||||||
|
}
|
||||||
|
|
||||||
|
if caps := context.StringSlice("cap-drop"); len(caps) > 0 {
|
||||||
|
for _, cap := range caps {
|
||||||
|
if !strings.HasPrefix(cap, "CAP_") {
|
||||||
|
return nil, fmt.Errorf("capabilities must be specified with 'CAP_' prefix")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
opts = append(opts, oci.WithDroppedCapabilities(caps))
|
||||||
|
}
|
||||||
|
|
||||||
seccompProfile := context.String("seccomp-profile")
|
seccompProfile := context.String("seccomp-profile")
|
||||||
|
|
||||||
if !context.Bool("seccomp") && seccompProfile != "" {
|
if !context.Bool("seccomp") && seccompProfile != "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user