You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
agent/usershell is the canonical place to resolve a user's home directory and shell, and usershell.EnvInfoer is the injectable seam that lets SSH sessions, the process API, and tests override that resolution (host vs container vs deterministic test environment). coder/coder#26102 routed working-directory resolution, MOTD/hushlogin lookup, manifest path expansion, and secret-file injection through EnvInfoer, and unexported usershell.HomeDir/usershell.Get so the host is no longer reachable directly from the resolution path.
Several agent subsystems still call os.UserHomeDir() (and user.Current()) directly, bypassing the injected EnvInfoer. In a container session, or a test with an injected environment, these resolve the host home directory instead of the intended one.
Every hit outside agent/usershell is a direct lookup that does not consult an EnvInfoer.
Desired outcome
These subsystems resolve the home directory through an EnvInfoer (the same one already plumbed into the agent), so injected and container environments are honored consistently. After this, the only direct home/user lookups in the agent tree should live inside agent/usershell, which backs SystemEnvInfo.
Constraints
agent/agentscripts, agent/agentcontextconfig, agent/agentfiles, and agent/agentcontainers/ignore do not currently receive an EnvInfoer. Threading the seam into each is the bulk of the work, and the reason this is split out from fix(agent): unify working directory resolution coder#26102 rather than bundled in.
agent/agentsocket/socket_windows.go calls user.Current() for the current user's SID to set Windows socket ACLs. That is a real OS-identity check, not home/shell resolution, and should stay on the OS user rather than an injectable seam. Leave it as-is.
Problem
agent/usershellis the canonical place to resolve a user's home directory and shell, andusershell.EnvInfoeris the injectable seam that lets SSH sessions, the process API, and tests override that resolution (host vs container vs deterministic test environment). coder/coder#26102 routed working-directory resolution, MOTD/hushlogin lookup, manifest path expansion, and secret-file injection throughEnvInfoer, and unexportedusershell.HomeDir/usershell.Getso the host is no longer reachable directly from the resolution path.Several agent subsystems still call
os.UserHomeDir()(anduser.Current()) directly, bypassing the injectedEnvInfoer. In a container session, or a test with an injected environment, these resolve the host home directory instead of the intended one.Remaining sites as of coder/coder#26102:
agent/agentssh/x11.goresolving~/.Xauthorityagent/agentscripts/agentscripts.goexpanding~in script log pathsagent/agentcontextconfig/resolve.goexpanding~in context-config pathsagent/agentfiles/ls.goresolving the home base forLSRelativityHomeagent/agentcontainers/ignore/dir.goresolving the global gitignore homeHow to verify
From the coder/coder repo root:
Every hit outside
agent/usershellis a direct lookup that does not consult anEnvInfoer.Desired outcome
These subsystems resolve the home directory through an
EnvInfoer(the same one already plumbed into the agent), so injected and container environments are honored consistently. After this, the only direct home/user lookups in the agent tree should live insideagent/usershell, which backsSystemEnvInfo.Constraints
agent/agentscripts,agent/agentcontextconfig,agent/agentfiles, andagent/agentcontainers/ignoredo not currently receive anEnvInfoer. Threading the seam into each is the bulk of the work, and the reason this is split out from fix(agent): unify working directory resolution coder#26102 rather than bundled in.agent/agentsocket/socket_windows.gocallsuser.Current()for the current user's SID to set Windows socket ACLs. That is a real OS-identity check, not home/shell resolution, and should stay on the OS user rather than an injectable seam. Leave it as-is.Follow-up to coder/coder#26102. Parent: #1560.