From 9647eb6a6b5607e9aac1e2c113e80f2e966ec0ac Mon Sep 17 00:00:00 2001 From: Ophestra Umiker Date: Mon, 7 Oct 2024 12:48:20 +0900 Subject: helper: separate pipes from Helper Upcoming bwrap helper implementation requires two sets of pipes to be managed, fd will also no longer be constant. Signed-off-by: Ophestra Umiker --- helper/stub.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'helper/stub.go') diff --git a/helper/stub.go b/helper/stub.go index 6a591733..b6b5d72c 100644 --- a/helper/stub.go +++ b/helper/stub.go @@ -1,6 +1,7 @@ package helper import ( + "flag" "io" "os" "os/exec" @@ -17,9 +18,17 @@ func InternalChildStub() { return } + argsFD := flag.Int("args", -1, "") + statFD := flag.Int("fd", -1, "") + _ = flag.CommandLine.Parse(os.Args[4:]) + // simulate args pipe behaviour func() { - f := os.NewFile(3, "|0") + if *argsFD == -1 { + panic("attempted to start helper without passing args pipe fd") + } + + f := os.NewFile(uintptr(*argsFD), "|0") if f == nil { panic("attempted to start helper without args pipe") } @@ -33,9 +42,13 @@ func InternalChildStub() { // simulate status pipe behaviour if os.Getenv(FortifyStatus) == "1" { + if *statFD == -1 { + panic("attempted to start helper with status reporting without passing status pipe fd") + } + wait = make(chan struct{}) go func() { - f := os.NewFile(4, "|1") + f := os.NewFile(uintptr(*statFD), "|1") if f == nil { panic("attempted to start with status reporting without status pipe") } -- cgit v1.3.1