diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-03-17 01:09:12 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-03-17 01:10:27 +0900 |
| commit | ee108603572101ad3c285830e04ee248916b6c5d (patch) | |
| tree | e3d2274301cf7f1ed39df9c510672745fbe0b08a /helper | |
| parent | 44277dc0f1fd1806f5ceea34246a4c805a06b61b (diff) | |
seccomp: install output atomically
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'helper')
| -rw-r--r-- | helper/bwrap/config_test.go | 6 | ||||
| -rw-r--r-- | helper/bwrap/seccomp.go | 9 |
2 files changed, 8 insertions, 7 deletions
diff --git a/helper/bwrap/config_test.go b/helper/bwrap/config_test.go index 678f49de..7e78c8fb 100644 --- a/helper/bwrap/config_test.go +++ b/helper/bwrap/config_test.go @@ -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 diff --git a/helper/bwrap/seccomp.go b/helper/bwrap/seccomp.go index 8e55171b..f5132be3 100644 --- a/helper/bwrap/seccomp.go +++ b/helper/bwrap/seccomp.go @@ -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)} |
