tailscale/ssh/tailssh
Kristoffer Dalby 9e547221a7 ssh/tailssh: deliver SIGHUP to the user shell, not just the incubator
The earlier SIGHUP work signalled cmd.Process.Pid, which is the
incubator. The user's shell is a grandchild and never saw the
signal, so any HUP-trapping cleanup the user installed was silently
skipped.

  - newIncubatorCommand sets Setpgid:true so the incubator and any
    children it spawns share a process group. The PTY path overrides
    this in startWithPTY with Setsid, which also creates a new pgrp,
    so PTY sessions get the property without further changes.
  - new helper terminateSession (per-OS) sends the signal to the
    negated PID so the kernel delivers it to every process in the
    group; ESRCH maps to nil because that just means the session
    already exited.
  - plan9 lacks Unix-style process groups, so terminateSession there
    falls back to Process.Signal.
  - killProcessOnContextDone routes through terminateSession and
    logs any error.

TestIntegrationSIGHUP was also broken: t.TempDir creates a
/tmp/<TestName>/NNN pair, both root-owned, with the parent at 0700
and the leaf at 0755. The incubator drops privileges to the test
user before running the trap, so the > redirect couldn't traverse
the parent or write the leaf; the trap fired but left no marker.
chmod the parent to 0755 and the leaf to 0777 so the dropped
shell can reach and write it. Cleanup stays with t.TempDir.

Updates #18256

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
2026-05-27 14:15:47 +00:00
..
testcontainers ssh/tailssh: speed up SSH integration tests 2026-04-13 14:18:27 -07:00
accept_env_test.go cmd/vet: add subtestnames analyzer; fix all existing violations 2026-04-05 15:52:51 -07:00
accept_env.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
auditd_linux_test.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
auditd_linux.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
c2n.go ipn/ipnlocal, feature/ssh: move SSH code out of LocalBackend to feature 2026-03-10 17:27:17 -07:00
hostkeys_test.go ipn/ipnlocal, feature/ssh: move SSH code out of LocalBackend to feature 2026-03-10 17:27:17 -07:00
hostkeys.go ssh: replace tempfork with tailscale/gliderssh 2026-04-07 11:59:38 +01:00
incubator_linux.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
incubator_plan9.go ssh/tailssh: deliver SIGHUP to the user shell, not just the incubator 2026-05-27 14:15:47 +00:00
incubator.go ssh/tailssh: deliver SIGHUP to the user shell, not just the incubator 2026-05-27 14:15:47 +00:00
privs_test.go tstest: add RequireRoot helper 2026-04-10 10:48:50 -07:00
tailssh_exitcodes_test.go ssh/tailssh: add integration tests for SSH exit-status and signals 2026-05-27 14:15:47 +00:00
tailssh_integration_exitcodes_test.go ssh/tailssh: deliver SIGHUP to the user shell, not just the incubator 2026-05-27 14:15:47 +00:00
tailssh_integration_test.go ipn/ipnlocal, all: split LocalBackend.NetMap into NetMapNoPeers / NetMapWithPeers 2026-04-30 11:14:06 -07:00
tailssh_test.go ssh/tailssh: add integration tests for SSH exit-status and signals 2026-05-27 14:15:47 +00:00
tailssh.go ssh/tailssh: deliver SIGHUP to the user shell, not just the incubator 2026-05-27 14:15:47 +00:00
user.go ssh/tailssh: fix default PATH for Debian 2026-04-09 11:57:40 -04:00