Skip to content

Commit 721fbce

Browse files
author
Ma Shimiao
committed
solve conflicting option problem
In my option, there is not any other good ways to solve conflicting options problem except adding note for warning. Signed-off-by: Ma Shimiao <[email protected]>
1 parent 1b3d6bd commit 721fbce

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed

cmd/oci-runtime-tool/generate.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
301301

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

304+
if context.Bool("process-cap-drop-all") {
305+
g.ClearProcessCapabilities()
306+
}
307+
304308
if context.IsSet("process-cap-add-ambient") {
305309
addCaps := context.StringSlice("process-cap-add-ambient")
306310
for _, cap := range addCaps {
@@ -346,10 +350,6 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
346350
}
347351
}
348352

349-
if context.Bool("process-cap-drop-all") {
350-
g.ClearProcessCapabilities()
351-
}
352-
353353
if context.IsSet("process-cap-drop-ambient") {
354354
dropCaps := context.StringSlice("process-cap-drop-ambient")
355355
for _, cap := range dropCaps {
@@ -699,6 +699,10 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
699699
}
700700
}
701701

702+
if context.Bool("linux-namespace-remove-all") {
703+
g.ClearLinuxNamespaces()
704+
}
705+
702706
if context.IsSet("linux-namespace-add") {
703707
namespaces := context.StringSlice("linux-namespace-add")
704708
for _, ns := range namespaces {
@@ -721,8 +725,8 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
721725
}
722726
}
723727

724-
if context.Bool("linux-namespace-remove-all") {
725-
g.ClearLinuxNamespaces()
728+
if context.Bool("process-rlimits-remove-all") {
729+
g.ClearProcessRlimits()
726730
}
727731

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

749-
if context.Bool("process-rlimits-remove-all") {
750-
g.ClearProcessRlimits()
753+
if context.Bool("linux-device-remove-all") {
754+
g.ClearLinuxDevices()
751755
}
752756

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

774-
if context.Bool("linux-device-remove-all") {
775-
g.ClearLinuxDevices()
776-
}
777-
778778
err := addSeccomp(context, g)
779779
return err
780780
}
@@ -1042,6 +1042,12 @@ func parseLinuxResourcesDeviceAccess(device string, g *generate.Generator) (rspe
10421042
}
10431043

10441044
func addSeccomp(context *cli.Context, g *generate.Generator) error {
1045+
if context.Bool("linux-seccomp-remove-all") {
1046+
err := g.RemoveAllSeccompRules()
1047+
if err != nil {
1048+
return err
1049+
}
1050+
}
10451051

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

1116-
if context.Bool("linux-seccomp-remove-all") {
1117-
err := g.RemoveAllSeccompRules()
1118-
if err != nil {
1119-
return err
1120-
}
1121-
}
11221122
return nil
11231123
}
11241124

man/oci-runtime-tool-generate.1.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ read the configuration from `config.json`.
165165

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

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

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

296-
**--linux-seccomp-only**==true|false
300+
**--linux-seccomp-only**=true|false
297301
Option to only export the seccomp section of output
298302

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)