seccomp: install output atomically
Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package bwrap_test
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"slices"
|
||||
"testing"
|
||||
@@ -12,8 +11,9 @@ import (
|
||||
)
|
||||
|
||||
func TestConfig_Args(t *testing.T) {
|
||||
seccomp.CPrintln = log.Println
|
||||
t.Cleanup(func() { seccomp.CPrintln = nil })
|
||||
oldF := seccomp.GetOutput()
|
||||
seccomp.SetOutput(t.Log)
|
||||
t.Cleanup(func() { seccomp.SetOutput(oldF) })
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
|
||||
@@ -48,20 +48,21 @@ func (c *Config) seccompArgs() FDBuilder {
|
||||
{c.Syscall.Bluetooth, seccomp.FlagBluetooth, "bluetooth"},
|
||||
}
|
||||
)
|
||||
if seccomp.CPrintln != nil {
|
||||
scmpPrintln := seccomp.GetOutput()
|
||||
if scmpPrintln != nil {
|
||||
optd = make([]string, 1, len(optCond)+1)
|
||||
optd[0] = "common"
|
||||
}
|
||||
for _, opt := range optCond {
|
||||
if opt.v {
|
||||
opts |= opt.o
|
||||
if seccomp.CPrintln != nil {
|
||||
if scmpPrintln != nil {
|
||||
optd = append(optd, opt.d)
|
||||
}
|
||||
}
|
||||
}
|
||||
if seccomp.CPrintln != nil {
|
||||
seccomp.CPrintln(fmt.Sprintf("seccomp flags: %s", optd))
|
||||
if scmpPrintln != nil {
|
||||
scmpPrintln(fmt.Sprintf("seccomp flags: %s", optd))
|
||||
}
|
||||
|
||||
return &seccompBuilder{seccomp.NewFile(opts)}
|
||||
|
||||
Reference in New Issue
Block a user