From 7ece75e4226309e8b2ccdee11306f914eb2f3e7b Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 30 Nov 2026 07:50:09 +0000 Subject: [PATCH] ssh/tailssh, go.mod: fix Plan 9 interactive SSH sessions Bump plan9netshell for go4org/plan9netshell@f7dfc18b3ab6ddfa769b8270ceb1c9dfa835af9a, which fixes interactive shells (broken since Go 1.25 by syscall.Exec), ^C, and hangup on disconnect. Also stop creating the Plan 9 incubator with exec.CommandContext, which killed it on any disconnect, unlike the graceful disconnect semantics the Unix monitor path now has. For PTY sessions that orphaned the shell and its foreground job. Now closing its stdio makes netshell hang up the shell instead. Updates #5794 Change-Id: I95cbca4997a6700c14d022fbf0d0c42486840782 Signed-off-by: Brad Fitzpatrick --- flake.nix | 2 +- flakehashes.json | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- shell.nix | 2 +- ssh/tailssh/incubator_plan9.go | 12 +++++++++--- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index 2a06f0f85..ed84cba30 100644 --- a/flake.nix +++ b/flake.nix @@ -172,4 +172,4 @@ }); }; } -# nix-direnv cache busting line: sha256-QsllX5yUsJznAf3niq8aKwbDO6Rut8Yyjl6FyCO7Kiw= +# nix-direnv cache busting line: sha256-UhlYeMCFqSuP6aLG3D9PFyjXf8ff68HO6MBvu/DDAOQ= diff --git a/flakehashes.json b/flakehashes.json index 741788301..f04be4b80 100644 --- a/flakehashes.json +++ b/flakehashes.json @@ -4,7 +4,7 @@ "sri": "sha256-Qmy06FkeFkjqCo1FLSD9dO7hTvdo/gC2VACJniuiQBU=" }, "vendor": { - "goModSum": "sha256-CQqT0MmBtyeIL6IdNcZWFaUDFU9z2IR7LKhTCmhrNl0=", - "sri": "sha256-QsllX5yUsJznAf3niq8aKwbDO6Rut8Yyjl6FyCO7Kiw=" + "goModSum": "sha256-8YZZZ5wSyCtYJiG3zRtOSYPBqDGW/Vbo2pIRFJROU+I=", + "sri": "sha256-UhlYeMCFqSuP6aLG3D9PFyjXf8ff68HO6MBvu/DDAOQ=" } } diff --git a/go.mod b/go.mod index 9da73454d..891810c46 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( github.com/go-logr/zapr v1.3.0 github.com/go-ole/go-ole v1.3.0 github.com/go4org/hashtriemap v0.0.0-20260925222741-44e5305f85d9 - github.com/go4org/plan9netshell v0.0.0-20250324183649-788daa080737 + github.com/go4org/plan9netshell v0.0.0-20261130214832-f7dfc18b3ab6 github.com/godbus/dbus/v5 v5.2.2 github.com/gokrazy/breakglass v0.0.0-20261129143625-dde5ec3a2b06 github.com/gokrazy/firmware v0.0.0-20261126122533-fe094a467208 diff --git a/go.sum b/go.sum index 0d0b072e6..044042376 100644 --- a/go.sum +++ b/go.sum @@ -493,8 +493,8 @@ github.com/go-xmlfmt/xmlfmt v1.1.3 h1:t8Ey3Uy7jDSEisW2K3somuMKIpzktkWptA0iFCnRUW github.com/go-xmlfmt/xmlfmt v1.1.3/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= github.com/go4org/hashtriemap v0.0.0-20260925222741-44e5305f85d9 h1:J8S+Ms89nvHX1F9Ma2m3KhdTl41ZhbFKMyAJqvDA+iE= github.com/go4org/hashtriemap v0.0.0-20260925222741-44e5305f85d9/go.mod h1:OGmRfY/9QEK2P5zCRtmqfbCF283xPkU2dvVA4MvbvpI= -github.com/go4org/plan9netshell v0.0.0-20250324183649-788daa080737 h1:cf60tHxREO3g1nroKr2osU3JWZsJzkfi7rEg+oAB0Lo= -github.com/go4org/plan9netshell v0.0.0-20250324183649-788daa080737/go.mod h1:MIS0jDzbU/vuM9MC4YnBITCv+RYuTRq8dJzmCrFsK9g= +github.com/go4org/plan9netshell v0.0.0-20261130214832-f7dfc18b3ab6 h1:CMyTWglRVWGWh9q2kNEm84/DewiLMsMQtcMmOjxbS0Q= +github.com/go4org/plan9netshell v0.0.0-20261130214832-f7dfc18b3ab6/go.mod h1:MIS0jDzbU/vuM9MC4YnBITCv+RYuTRq8dJzmCrFsK9g= github.com/gobuffalo/flect v1.0.3 h1:xeWBM2nui+qnVvNM4S3foBhCAL2XgPU+a7FdpelbTq4= github.com/gobuffalo/flect v1.0.3/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= diff --git a/shell.nix b/shell.nix index 508d26f99..12a8a3711 100644 --- a/shell.nix +++ b/shell.nix @@ -16,4 +16,4 @@ ) { src = ./.; }).shellNix -# nix-direnv cache busting line: sha256-QsllX5yUsJznAf3niq8aKwbDO6Rut8Yyjl6FyCO7Kiw= +# nix-direnv cache busting line: sha256-UhlYeMCFqSuP6aLG3D9PFyjXf8ff68HO6MBvu/DDAOQ= diff --git a/ssh/tailssh/incubator_plan9.go b/ssh/tailssh/incubator_plan9.go index 63b4a5745..b1bab372b 100644 --- a/ssh/tailssh/incubator_plan9.go +++ b/ssh/tailssh/incubator_plan9.go @@ -43,7 +43,13 @@ func registerIncubator() { // `tailscaled be-child ssh` as the entrypoint. // // If ss.srv.tailscaledPath is empty, this method is equivalent to -// exec.CommandContext. +// exec.Command. +// +// The command is not tied to ss.ctx: canceling the session must not kill +// the child. A disconnect closes the child's stdio, which makes netshell +// hang up the shell's note group the way closing a PTY master signals +// the foreground process group on Unix. Mandated terminations signal the +// child explicitly in [sshSession.hangupProcess]. // // It also returns forwardedEnv, the client-forwarded environment variables // accepted by the acceptEnv policy. These may contain secrets, so the caller @@ -77,7 +83,7 @@ func (ss *sshSession) newIncubatorCommand(logf logger.Logf) (cmd *exec.Cmd, forw loginShell := ss.conn.localUser.LoginShell() logf("directly running /bin/rc -c %q", ss.RawCommand()) - return exec.CommandContext(ss.ctx, loginShell, "-c", ss.RawCommand()), nil, nil + return exec.Command(loginShell, "-c", ss.RawCommand()), nil, nil } lu := ss.conn.localUser @@ -140,7 +146,7 @@ func (ss *sshSession) newIncubatorCommand(logf logger.Logf) (cmd *exec.Cmd, forw } } - return exec.CommandContext(ss.ctx, ss.conn.srv.tailscaledPath, incubatorArgs...), forwardedEnv, nil + return exec.Command(ss.conn.srv.tailscaledPath, incubatorArgs...), forwardedEnv, nil } var debugTest atomic.Bool