diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-10-07 12:48:20 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-10-07 12:48:20 +0900 |
| commit | 9647eb6a6b5607e9aac1e2c113e80f2e966ec0ac (patch) | |
| tree | 2f314f8669742a817df0057ceab79891b36bea9d /helper/stub.go | |
| parent | 18d9ce733e19c500ca04b4e744e6cdc5c6faf137 (diff) | |
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 <cat@ophivana.moe>
Diffstat (limited to 'helper/stub.go')
| -rw-r--r-- | helper/stub.go | 17 |
1 files changed, 15 insertions, 2 deletions
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") } |
