aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/outcome.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-10-10 20:12:05 +0900
committerOphestra <cat@gensokyo.uk>2025-10-10 20:15:58 +0900
commit24de7c50a0ea7000c3a49c56b91db9aa72abdd28 (patch)
treeaa43fa13b27a88ec153a7b83550c45c7fd1db76e /internal/app/outcome.go
parentf6dd9dab6a91c8c39ea2a5afbca50e427e6a21ba (diff)
internal/app: relocate state initialisation
This is useful for testing. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/outcome.go')
-rw-r--r--internal/app/outcome.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/internal/app/outcome.go b/internal/app/outcome.go
index 4d2cd713..4daa8da6 100644
--- a/internal/app/outcome.go
+++ b/internal/app/outcome.go
@@ -2,7 +2,6 @@ package app
import (
"errors"
- "os"
"strconv"
"hakurei.app/container"
@@ -72,10 +71,16 @@ func (s *outcomeState) valid() bool {
s.EnvPaths != nil
}
-// populateEarly populates exported fields via syscallDispatcher.
-// This must only be called from the priv side.
-func (s *outcomeState) populateEarly(k syscallDispatcher, msg message.Msg) {
- s.Shim = &shimParams{PrivPID: os.Getpid(), Verbose: msg.IsVerbose()}
+// newOutcomeState returns the address of a new outcomeState with its exported fields populated via syscallDispatcher.
+func newOutcomeState(k syscallDispatcher, msg message.Msg, id *state.ID, config *hst.Config, hsu *Hsu) *outcomeState {
+ s := outcomeState{
+ Shim: &shimParams{PrivPID: k.getpid(), Verbose: msg.IsVerbose()},
+ ID: id,
+ Identity: config.Identity,
+ UserID: hsu.MustIDMsg(msg),
+ EnvPaths: copyPaths(k),
+ Container: config.Container,
+ }
// enforce bounds and default early
if s.Container.WaitDelay < 0 {
@@ -94,7 +99,7 @@ func (s *outcomeState) populateEarly(k syscallDispatcher, msg message.Msg) {
s.Mapuid, s.Mapgid = k.overflowUid(msg), k.overflowGid(msg)
}
- return
+ return &s
}
// populateLocal populates unexported fields from transmitted exported fields.