aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-04-07 15:50:59 +0900
committerOphestra <cat@gensokyo.uk>2026-04-07 16:05:33 +0900
commit062edb3487c1cc116cae78bf77420b65c43517d1 (patch)
treeac91267721d7a288ea301b060b0110aa5d3b9b9a /internal
parente4355279a1624833e36455a1a85788dbe091464e (diff)
container: remove setup pipe helper
The API forces use of finalizer to close the read end of the setup pipe, which is no longer considered acceptable. Exporting this as part of package container also imposes unnecessary maintenance burden. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
-rw-r--r--internal/outcome/process.go22
1 files changed, 13 insertions, 9 deletions
diff --git a/internal/outcome/process.go b/internal/outcome/process.go
index 9b8fc537..44a62463 100644
--- a/internal/outcome/process.go
+++ b/internal/outcome/process.go
@@ -13,7 +13,6 @@ import (
"time"
"hakurei.app/check"
- "hakurei.app/container"
"hakurei.app/fhs"
"hakurei.app/hst"
"hakurei.app/internal/info"
@@ -372,17 +371,18 @@ func (k *outcome) start(ctx context.Context, msg message.Msg,
// shim runs in the same session as monitor; see shim.go for behaviour
cmd.Cancel = func() error { return cmd.Process.Signal(syscall.SIGCONT) }
- var shimPipe *os.File
- if fd, w, err := container.Setup(&cmd.ExtraFiles); err != nil {
+ var shimPipe [2]*os.File
+ if r, w, err := os.Pipe(); err != nil {
return cmd, nil, &hst.AppError{Step: "create shim setup pipe", Err: err}
} else {
- shimPipe = w
cmd.Env = []string{
// passed through to shim by hsu
- shimEnv + "=" + strconv.Itoa(fd),
+ shimEnv + "=" + strconv.Itoa(3+len(cmd.ExtraFiles)),
// interpreted by hsu
"HAKUREI_IDENTITY=" + k.state.identity.String(),
}
+ cmd.ExtraFiles = append(cmd.ExtraFiles, r)
+ shimPipe[0], shimPipe[1] = r, w
}
if len(k.supp) > 0 {
@@ -393,12 +393,16 @@ func (k *outcome) start(ctx context.Context, msg message.Msg,
msg.Verbosef("setuid helper at %s", hsuPath)
if err := cmd.Start(); err != nil {
+ _, _ = shimPipe[0].Close(), shimPipe[1].Close()
msg.Resume()
- return cmd, shimPipe, &hst.AppError{Step: "start setuid wrapper", Err: err}
+ return cmd, nil, &hst.AppError{Step: "start setuid wrapper", Err: err}
+ }
+ if err := shimPipe[0].Close(); err != nil {
+ msg.Verbose(err)
}
*startTime = time.Now().UTC()
- return cmd, shimPipe, nil
+ return cmd, shimPipe[1], nil
}
// serveShim serves outcomeState through the shim setup pipe.
@@ -411,11 +415,11 @@ func serveShim(msg message.Msg, shimPipe *os.File, state *outcomeState) error {
msg.Verbose(err.Error())
}
if err := gob.NewEncoder(shimPipe).Encode(state); err != nil {
+ _ = shimPipe.Close()
msg.Resume()
return &hst.AppError{Step: "transmit shim config", Err: err}
}
- _ = shimPipe.Close()
- return nil
+ return shimPipe.Close()
}
// printMessageError prints the error message according to [message.GetMessage],