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.
This commit is contained in:
Levi Neely 2026-07-31 09:22:43 +02:00
parent c846220b69
commit ae59151344
2 changed files with 7 additions and 0 deletions

View File

@ -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)
}
}
}
}

View File

@ -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 {