Skip to content

Commit 2ed047a

Browse files
author
Mrunal Patel
authored
Merge pull request #399 from Mashimiao/seccomp-default-fix
fix seccomp-default parse and remove problem
2 parents 032091c + 7de2ac5 commit 2ed047a

File tree

4 files changed

+10
-20
lines changed

4 files changed

+10
-20
lines changed

completions/bash/oci-runtime-tool

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ __oci-runtime-tool_complete_seccomp_arches() {
159159
# context of oci-runtime-tool containers.
160160
__oci-runtime-tool_complete_seccomp_actions() {
161161
COMPREPLY=( $( compgen -W "
162-
SCMP_ACT_ALLOW
163-
SCMP_ACT_ERRNO
164-
SCMP_ACT_KILL
165-
SCMP_ACT_TRACE
166-
SCMP_ACT_TRAP
162+
allow
163+
errno
164+
kill
165+
trace
166+
trap
167167
" -- "$cur" ) )
168168
}
169169
__oci-runtime-tool_complete_capabilities() {

generate/seccomp/parse_action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func ParseDefaultAction(action string, config *rspec.LinuxSeccomp) error {
9797
return err
9898
}
9999
config.DefaultAction = defaultAction
100-
err = RemoveAllMatchingRules(config, action)
100+
err = RemoveAllMatchingRules(config, defaultAction)
101101
if err != nil {
102102
return err
103103
}

generate/seccomp/parse_remove.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ func RemoveAction(arguments string, config *rspec.LinuxSeccomp) error {
1515
return fmt.Errorf("Cannot remove action from nil Seccomp pointer")
1616
}
1717

18-
var syscallsToRemove []string
19-
if strings.Contains(arguments, ",") {
20-
syscallsToRemove = strings.Split(arguments, ",")
21-
} else {
22-
syscallsToRemove = append(syscallsToRemove, arguments)
23-
}
18+
syscallsToRemove := strings.Split(arguments, ",")
2419

2520
for counter, syscallStruct := range config.Syscalls {
2621
if reflect.DeepEqual(syscallsToRemove, syscallStruct.Names) {
@@ -42,16 +37,11 @@ func RemoveAllSeccompRules(config *rspec.LinuxSeccomp) error {
4237
}
4338

4439
// RemoveAllMatchingRules will remove any syscall rules that match the specified action
45-
func RemoveAllMatchingRules(config *rspec.LinuxSeccomp, action string) error {
40+
func RemoveAllMatchingRules(config *rspec.LinuxSeccomp, seccompAction rspec.LinuxSeccompAction) error {
4641
if config == nil {
4742
return fmt.Errorf("Cannot remove action from nil Seccomp pointer")
4843
}
4944

50-
seccompAction, err := parseAction(action)
51-
if err != nil {
52-
return err
53-
}
54-
5545
for _, syscall := range config.Syscalls {
5646
if reflect.DeepEqual(syscall.Action, seccompAction) {
5747
RemoveAction(strings.Join(syscall.Names, ","), config)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@ read the configuration from `config.json`.
201201

202202
**--linux-seccomp-default**=ACTION
203203
Specifies the the default action of Seccomp syscall restrictions and removes existing restrictions with the specified action
204-
Values: KILL,ERRNO,TRACE,ALLOW
204+
Values: kill, trap, errno, trace, allow
205205

206206
**--linux-seccomp-default-force**=ACTION
207207
Specifies the the default action of Seccomp syscall restrictions
208-
Values: KILL,ERRNO,TRACE,ALLOW
208+
Values: kill, trap, errno, trace, allow
209209

210210
**--linux-seccomp-errno**=SYSCALL
211211
Specifies syscalls to create seccomp rule to respond with ERRNO.

0 commit comments

Comments
 (0)