Files
tailscale/ssh/tailssh
Kristoffer Dalby 1587e7dea6 ssh/tailssh: only use /usr/bin/login for interactive TTY shells on darwin
macOS /usr/bin/login -pq exits 0 once the child is spawned, so the
child's exit status is lost: `ssh mac exit 5` returned 0, `ssh mac
/nonexistent` returned 0 instead of 127. We can't change Apple's binary,
so don't use it where it misbehaves.

Route exec sessions (with and without a TTY) and non-TTY shells through
handleSSHInProcess, the path Linux already uses, which runs the command
via cmd.Run + os.Exit(code). Only interactive TTY shells keep login.

The trade: maybeStartLoginSession is a no-op outside linux and findSU
returns "" for non-linux, so the three redirected darwin shapes now get
no PAM "remote" session and no utmpx entry. They are absent from `who`
and `last`. Interactive TTY shells, where that accounting matters most,
are unaffected.

New pure shouldUseLogin holds the per-GOOS policy so TestShouldUseLogin
can pin all four darwin combinations on any host. TestOpenSSHExitCodes
gains tty_exec and stdin_shell cases, exercised by the macOS CI job.

Updates #18256

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
2026-07-27 12:56:33 +00:00
..
2026-04-10 10:48:50 -07:00