helper/bwrap: implement sync fd
All checks were successful
test / test (push) Successful in 38s

This is required by wayland security-context-v1.

Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
2024-12-06 04:21:37 +09:00
parent 38e92edb8e
commit 8d0573405a
3 changed files with 26 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ package helper
import (
"errors"
"io"
"os"
"os/exec"
"strconv"
"sync"
@@ -19,6 +20,8 @@ type bubblewrap struct {
// bwrap pipes
p *pipes
// sync pipe
sync *os.File
// returns an array of arguments passed directly
// to the child process spawned by bwrap
argF func(argsFD, statFD int) []string
@@ -72,6 +75,11 @@ func (b *bubblewrap) StartNotify(ready chan error) error {
b.Cmd.Env = append(b.Cmd.Env, FortifyHelper+"=1", FortifyStatus+"=-1")
}
if b.sync != nil {
b.Cmd.Args = append(b.Cmd.Args, "--sync-fd", strconv.Itoa(3+len(b.Cmd.ExtraFiles)))
b.Cmd.ExtraFiles = append(b.Cmd.ExtraFiles, b.sync)
}
if err := b.Cmd.Start(); err != nil {
return err
}
@@ -131,6 +139,7 @@ func NewBwrap(conf *bwrap.Config, wt io.WriterTo, name string, argF func(argsFD,
b.p = &pipes{args: args}
}
b.sync = conf.Sync()
b.argF = argF
b.name = name
if wt != nil {