package main
import (
"fmt"
libseccomp "github.com/seccomp/libseccomp-golang"
"os"
"os/exec"
)
func whiteList(syscalls []string) {
filter, err := libseccomp.NewFilter(libseccomp.ActKill)
if err != nil {
fmt.Printf("Error creating filter: %s\n", err)
}
for _, element := range syscalls {
syscallID, err := libseccomp.GetSyscallFromName(element)
if err != nil {
panic(err)
}
filter.AddRule(syscallID, libseccomp.ActAllow)
}
filter.Load()
}
func main() {
var syscalls = []string{}
whiteList(syscalls)
cmd := exec.Command("/bin/ls")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
fmt.Println(err)
}
}
我认为该程序将被杀死,因为systemcall白名单为空。但是,它一直挂着,直到我输入Ctrl + C。我的用法有误吗?我的理解错了吗?在golang中如何正确使用seccomp?