mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-09 05:33:27 +09:00
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>