aboutsummaryrefslogtreecommitdiffhomepage
path: root/helper/bwrap.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-01-19 18:38:13 +0900
committerOphestra <cat@gensokyo.uk>2025-01-19 18:38:13 +0900
commit2f705068658bf9c47a5fa829105111e46a7732a0 (patch)
tree4f75a66cb84cf5452c865afbdb9784adfded79b3 /helper/bwrap.go
parentcae567c1090ef12e9837f7dec4f43d030ec8f6b2 (diff)
helper/bwrap: move sync to helper state
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'helper/bwrap.go')
-rw-r--r--helper/bwrap.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/helper/bwrap.go b/helper/bwrap.go
index 9c9f37d9..966e6fbf 100644
--- a/helper/bwrap.go
+++ b/helper/bwrap.go
@@ -21,7 +21,8 @@ type bubblewrap struct {
// bwrap pipes
control *pipes
- // sync pipe
+ // keep this fd open while sandbox is running
+ // (--sync-fd FD)
sync *os.File
// returns an array of arguments passed directly
// to the child process spawned by bwrap
@@ -119,8 +120,12 @@ func (b *bubblewrap) Unwrap() *exec.Cmd {
// MustNewBwrap initialises a new Bwrap instance with wt as the null-terminated argument writer.
// If wt is nil, the child process spawned by bwrap will not get an argument pipe.
// Function argF returns an array of arguments passed directly to the child process.
-func MustNewBwrap(conf *bwrap.Config, wt io.WriterTo, name string, argF func(argsFD, statFD int) []string) Helper {
- b, err := NewBwrap(conf, wt, name, argF)
+func MustNewBwrap(
+ conf *bwrap.Config, name string,
+ wt io.WriterTo, argF func(argsFD, statFD int) []string,
+ syncFd *os.File,
+) Helper {
+ b, err := NewBwrap(conf, name, wt, argF, syncFd)
if err != nil {
panic(err.Error())
} else {
@@ -131,7 +136,11 @@ func MustNewBwrap(conf *bwrap.Config, wt io.WriterTo, name string, argF func(arg
// NewBwrap initialises a new Bwrap instance with wt as the null-terminated argument writer.
// If wt is nil, the child process spawned by bwrap will not get an argument pipe.
// Function argF returns an array of arguments passed directly to the child process.
-func NewBwrap(conf *bwrap.Config, wt io.WriterTo, name string, argF func(argsFD, statFD int) []string) (Helper, error) {
+func NewBwrap(
+ conf *bwrap.Config, name string,
+ wt io.WriterTo, argF func(argsFD, statFD int) []string,
+ syncFd *os.File,
+) (Helper, error) {
b := new(bubblewrap)
if args, err := NewCheckedArgs(conf.Args()); err != nil {
@@ -140,7 +149,7 @@ func NewBwrap(conf *bwrap.Config, wt io.WriterTo, name string, argF func(argsFD,
b.control = &pipes{args: args}
}
- b.sync = conf.Sync()
+ b.sync = syncFd
b.argF = argF
b.name = name
if wt != nil {