mirror of
https://github.com/tailscale/tailscale.git
synced 2026-12-04 07:32:19 -08:00
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:
1 parent
f5fdb18b2e
commit
b1582deed4
2 files changed
+6
-3
No files matched your search
@@ -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)),
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user