diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-05 03:31:43 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-05 03:53:23 +0900 |
| commit | 92b83bd599adf085c1a2a9c73eeb6b6dc1eee6e4 (patch) | |
| tree | d1ca10fdb89e9f0ccb607d4a0f4c2f36c83321f1 /internal | |
| parent | 8ace2148326d85312a157e19e596978361e9285d (diff) | |
internal/app: apply pd behaviour to outcomeState
This avoids needlessly clobbering hst.Config.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/app/finalise.go | 31 | ||||
| -rw-r--r-- | internal/app/spx11.go | 4 |
2 files changed, 17 insertions, 18 deletions
diff --git a/internal/app/finalise.go b/internal/app/finalise.go index df2f0fb0..f5ae398c 100644 --- a/internal/app/finalise.go +++ b/internal/app/finalise.go @@ -102,14 +102,22 @@ func (k *outcome) finalise(ctx context.Context, msg container.Msg, id *state.ID, } } + s := outcomeState{ + ID: id, + Identity: config.Identity, + UserID: (&Hsu{k: k}).MustIDMsg(msg), + EnvPaths: copyPaths(k.syscallDispatcher), + Container: config.Container, + } + // permissive defaults - if config.Container == nil { + if s.Container == nil { msg.Verbose("container configuration not supplied, PROCEED WITH CAUTION") if config.Shell == nil { config.Shell = container.AbsFHSRoot.Append("bin", "sh") - s, _ := k.lookupEnv("SHELL") - if a, err := container.NewAbs(s); err == nil { + shell, _ := k.lookupEnv("SHELL") + if a, err := container.NewAbs(shell); err == nil { config.Shell = a } } @@ -166,7 +174,7 @@ func (k *outcome) finalise(ctx context.Context, msg container.Msg, id *state.ID, }}, ) - config.Container = conf + s.Container = conf } // late nil checks for pd behaviour @@ -179,23 +187,14 @@ func (k *outcome) finalise(ctx context.Context, msg container.Msg, id *state.ID, // enforce bounds and default early kp.waitDelay = shimWaitTimeout - if config.Container.WaitDelay <= 0 { + if s.Container.WaitDelay <= 0 { kp.waitDelay += DefaultShimWaitDelay - } else if config.Container.WaitDelay > MaxShimWaitDelay { + } else if s.Container.WaitDelay > MaxShimWaitDelay { kp.waitDelay += MaxShimWaitDelay } else { - kp.waitDelay += config.Container.WaitDelay + kp.waitDelay += s.Container.WaitDelay } - s := outcomeState{ - ID: id, - Identity: config.Identity, - UserID: (&Hsu{k: k}).MustIDMsg(msg), - EnvPaths: copyPaths(k.syscallDispatcher), - - // TODO(ophestra): apply pd behaviour here instead of clobbering hst.Config - Container: config.Container, - } if s.Container.MapRealUID { s.Mapuid, s.Mapgid = k.getuid(), k.getgid() } else { diff --git a/internal/app/spx11.go b/internal/app/spx11.go index 2e515cd4..0d287e05 100644 --- a/internal/app/spx11.go +++ b/internal/app/spx11.go @@ -20,7 +20,7 @@ type spX11Op struct { Display string } -func (s *spX11Op) toSystem(state *outcomeStateSys, config *hst.Config) error { +func (s *spX11Op) toSystem(state *outcomeStateSys, _ *hst.Config) error { if d, ok := state.k.lookupEnv("DISPLAY"); !ok { return newWithMessage("DISPLAY is not set") } else { @@ -46,7 +46,7 @@ func (s *spX11Op) toSystem(state *outcomeStateSys, config *hst.Config) error { } } else { state.sys.UpdatePermType(hst.EX11, socketPath, acl.Read, acl.Write, acl.Execute) - if !config.Container.HostAbstract { + if !state.Container.HostAbstract { s.Display = "unix:" + socketPath.String() } } |
