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:
parent
c846220b69
commit
ae59151344
|
|
@ -266,6 +266,9 @@ func (ag *Agent) SetSessionEnv(sessionID string) {
|
||||||
if ag.id != "" {
|
if ag.id != "" {
|
||||||
es.SetEnv("OLLIE_UNAME", ag.id)
|
es.SetEnv("OLLIE_UNAME", ag.id)
|
||||||
}
|
}
|
||||||
|
if u := os.Getenv("USER"); u != "" {
|
||||||
|
es.SetEnv("USER", u)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -516,6 +516,10 @@ func (e *Server) executeWithStdin(ctx context.Context, code, language string, ti
|
||||||
cmd.Env = append(cmd.Env, k+"="+v)
|
cmd.Env = append(cmd.Env, k+"="+v)
|
||||||
}
|
}
|
||||||
e.envMu.RUnlock()
|
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.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||||
cmd.Cancel = func() error {
|
cmd.Cancel = func() error {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue