ssh/tailssh: set $LOGNAME to same value as $USER in incubator

When the ssh incubator runs the shell itself instead of using `su` or `login`,
it needs to set the `$LOGNAME` environment variable. Just like OpenSSH `sshd`,
it sets this to the same value as `$USER`.

Updates tailscale/corp#50380

Signed-off-by: Percy Wegmann <[email protected]>
This commit is contained in:
Percy Wegmann authored and Percy Wegmann committed 2026-10-26 17:25:45 -05:00
1 parent f5fdb18b2e
commit b1582deed4
2 files changed
+6 -3

No files matched your search

+3
View File
@@ -1273,6 +1273,9 @@ func envForUser(u *userMeta) []string {
return []string{
fmt.Sprintf("SHELL=%s", u.LoginShell()),
fmt.Sprintf("USER=%s", u.Username),
// Some systems require $LOGNAME. Just like OpenSSH sshd, set it to the
// same value as $USER.
fmt.Sprintf("LOGNAME=%s", u.Username),
fmt.Sprintf("HOME=%s", u.HomeDir),
fmt.Sprintf("PATH=%s", defaultPathForUser(u)),
}
+3 -3
View File
@@ -178,9 +178,9 @@ func TestIncubatorEnvServerOnly(t *testing.T) {
}
}
}
// USER/HOME come from the server; TERM is the one client-controlled value
// allowed in (OpenSSH parity).
for _, want := range []string{"USER=alice", "HOME=/home/alice", "TERM=xterm-256color"} {
// USER/LOGNAME/HOME come from the server; TERM is the one client-controlled
// value allowed in (OpenSSH parity).
for _, want := range []string{"USER=alice", "LOGNAME=alice", "HOME=/home/alice", "TERM=xterm-256color"} {
if !slices.Contains(env, want) {
t.Errorf("%q missing from child environment: %q", want, env)
}