Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions cmd/oci-runtime-tool/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {

g.SetupPrivileged(context.Bool("privileged"))

if context.Bool("process-cap-drop-all") {
g.ClearProcessCapabilities()
}

if context.IsSet("process-cap-add-ambient") {
addCaps := context.StringSlice("process-cap-add-ambient")
for _, cap := range addCaps {
Expand Down Expand Up @@ -346,10 +350,6 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
}
}

if context.Bool("process-cap-drop-all") {
g.ClearProcessCapabilities()
}

if context.IsSet("process-cap-drop-ambient") {
dropCaps := context.StringSlice("process-cap-drop-ambient")
for _, cap := range dropCaps {
Expand Down Expand Up @@ -699,6 +699,10 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
}
}

if context.Bool("linux-namespace-remove-all") {
g.ClearLinuxNamespaces()
}

if context.IsSet("linux-namespace-add") {
namespaces := context.StringSlice("linux-namespace-add")
for _, ns := range namespaces {
Expand All @@ -721,8 +725,8 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
}
}

if context.Bool("linux-namespace-remove-all") {
g.ClearLinuxNamespaces()
if context.Bool("process-rlimits-remove-all") {
g.ClearProcessRlimits()
}

if context.IsSet("process-rlimits-add") {
Expand All @@ -746,8 +750,8 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
}
}

if context.Bool("process-rlimits-remove-all") {
g.ClearProcessRlimits()
if context.Bool("linux-device-remove-all") {
g.ClearLinuxDevices()
}

if context.IsSet("linux-device-add") {
Expand All @@ -771,10 +775,6 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
}
}

if context.Bool("linux-device-remove-all") {
g.ClearLinuxDevices()
}

err := addSeccomp(context, g)
return err
}
Expand Down Expand Up @@ -1042,6 +1042,12 @@ func parseLinuxResourcesDeviceAccess(device string, g *generate.Generator) (rspe
}

func addSeccomp(context *cli.Context, g *generate.Generator) error {
if context.Bool("linux-seccomp-remove-all") {
err := g.RemoveAllSeccompRules()
if err != nil {
return err
}
}

// Set the DefaultAction of seccomp
if context.IsSet("linux-seccomp-default") {
Expand Down Expand Up @@ -1113,12 +1119,6 @@ func addSeccomp(context *cli.Context, g *generate.Generator) error {
}
}

if context.Bool("linux-seccomp-remove-all") {
err := g.RemoveAllSeccompRules()
if err != nil {
return err
}
}
return nil
}

Expand Down
16 changes: 13 additions & 3 deletions man/oci-runtime-tool-generate.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ read the configuration from `config.json`.

**--linux-device-remove-all**=true|false
Remove all devices for linux inside the container. The default is *false*.
This option conflicts with --linux-device-add and --linux-device-remove.
When combined with them, no matter what the options' order is, parse this option first.

**--linux-device-cgroup-add**=allow|deny[,type=TYPE][,major=MAJOR][,minor=MINOR][,access=ACCESS]
Add a device control rule.
Expand Down Expand Up @@ -241,6 +243,8 @@ read the configuration from `config.json`.
**--linux-namespace-remove-all**=true|false
Removes all namespaces from the set of namespaces configured for a container,
such that the container will effectively run on the host.
This option conflicts with --linux-namespace-add and --linux-namespace-remove.
When combined with them, no matter what the options' order is, parse this option first.

**--linux-network-classid**=CLASSID
Specifies network class identifier which will be tagged by container's network packets.
Expand Down Expand Up @@ -293,14 +297,16 @@ read the configuration from `config.json`.
**--linux-seccomp-kill**=SYSCALL
Specifies syscalls to create seccomp rule to respond with KILL.

**--linux-seccomp-only**==true|false
**--linux-seccomp-only**=true|false
Option to only export the seccomp section of output

**--linux-seccomp-remove**=[]
Specifies syscall restrictions to remove from the configuration.

**--linux-seccomp-remove-all**==true|false
**--linux-seccomp-remove-all**=true|false
Option to remove all syscall restrictions.
This option conflicts with other --linux-seccomp-xxx options.
When combined with them, no matter what the options' order is, parse this option first.

**--linux-seccomp-trace**=SYSCALL
Specifies syscalls to create seccomp rule to respond with TRACE.
Expand Down Expand Up @@ -371,8 +377,10 @@ read the configuration from `config.json`.
**--process-cap-add-permitted**=[]
Add Linux permitted capabilities

**--process-cap-drop-all**true|false
**--process-cap-drop-all**=true|false
Drop all Linux capabilities
This option conflicts with other cap options, as --process-cap-*.
When combined with them, no matter what the options' order is, parse this option first.

**--process-cap-drop-ambient**=[]
Drop Linux ambient capabilities
Expand Down Expand Up @@ -417,6 +425,8 @@ read the configuration from `config.json`.

**--process-rlimits-remove-all**=true|false
Remove all resource limits for process inside the container. The default is *false*.
This option conflicts with --linux-rlimits-add and --linux-rlimits-remove.
When combined with them, no matter what the options' order is, parse this option first.

**--process-terminal**=true|false
Specifies whether a terminal is attached to the process. The default is *false*.
Expand Down