From ae59151344f22bd90fdb4388475cc4108e45df5f Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Fri, 31 Jul 2026 09:22:43 +0200 Subject: [PATCH] toolsrv: export USER and NAMESPACE to shell environment ollie-9p computes its namespace path from $USER and $DISPLAY via client.Namespace(). When run inside the sandboxed shell, USER was not guaranteed to be in the environment, producing /tmp/ns..:0/ollie. Fix: explicitly inject USER into envExtra in SetSessionEnv (alongside OLLIE_SESSION_ID and OLLIE_UNAME). Also export the computed NAMESPACE to cmd.Env so ollie-9p can use it directly without recomputing. --- agent/agent.go | 3 +++ toolsrv/shell.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/agent/agent.go b/agent/agent.go index bd8aca9..00fae6a 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -266,6 +266,9 @@ func (ag *Agent) SetSessionEnv(sessionID string) { if ag.id != "" { es.SetEnv("OLLIE_UNAME", ag.id) } + if u := os.Getenv("USER"); u != "" { + es.SetEnv("USER", u) + } } } } diff --git a/toolsrv/shell.go b/toolsrv/shell.go index 23dc347..ca9af4e 100644 --- a/toolsrv/shell.go +++ b/toolsrv/shell.go @@ -516,6 +516,10 @@ func (e *Server) executeWithStdin(ctx context.Context, code, language string, ti cmd.Env = append(cmd.Env, k+"="+v) } e.envMu.RUnlock() + // Export computed NAMESPACE so tools like ollie-9p can find the server. + if ns := envMap["NAMESPACE"]; ns != "" { + cmd.Env = append(cmd.Env, "NAMESPACE="+ns) + } cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} cmd.Cancel = func() error {