helper/bwrap: move sync to helper state
All checks were successful
Build / Create distribution (push) Successful in 1m25s
Test / Run NixOS test (push) Successful in 3m33s

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-01-19 18:38:13 +09:00
parent cae567c109
commit 2f70506865
10 changed files with 76 additions and 74 deletions

View File

@@ -24,6 +24,8 @@ type Shim struct {
killFallback chan error
// monitor to shim encoder
encoder *gob.Encoder
// bwrap --sync-fd value
sync *uintptr
}
func (s *Shim) String() string {
@@ -46,8 +48,8 @@ func (s *Shim) Start(
aid string,
// string representation of supplementary group ids
supp []string,
// shim setup payload
payload *Payload,
// bwrap --sync-fd
syncFd *os.File,
) (*time.Time, error) {
// prepare user switcher invocation
var fsu string
@@ -80,9 +82,9 @@ func (s *Shim) Start(
s.cmd.Dir = "/"
// pass sync fd if set
if payload.Bwrap.Sync() != nil {
fd := proc.ExtraFile(s.cmd, payload.Bwrap.Sync())
payload.Sync = &fd
if syncFd != nil {
fd := proc.ExtraFile(s.cmd, syncFd)
s.sync = &fd
}
fmsg.VPrintln("starting shim via fsu:", s.cmd)
@@ -106,6 +108,7 @@ func (s *Shim) Serve(ctx context.Context, payload *Payload) error {
}
defer func() { killShim() }()
payload.Sync = s.sync
encodeErr := make(chan error)
go func() { encodeErr <- s.encoder.Encode(payload) }()