tailscale/ssh/tailssh
Maisem Ali 0b95ace349 ssh/tailssh: take explicit ownership of stdin,stderr,stdout
We were using `cmd.Std{in,err,out}Pipe` and would then spin
off goroutines to copy that data back and forth between the
child process and the session. We would then concurrently
call `cmd.Wait()` to wait for the process to exit. However,
this interaction is documented as unsafe.

```
StdoutPipe returns a pipe that will be connected to the command's standard output when the command starts.

Wait will close the pipe after seeing the command exit, so most callers need not close the pipe themselves.
It is thus incorrect to call Wait before all reads from the pipe have completed.
```

Instead of doing that, take ownership of the pipe and explicitly
close them when the session completes.

Fixes #7601

Co-authored-by: Joe Tsai <joetsai@digital-static.net>
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-06-20 18:15:09 -07:00
..
incubator.go ssh/tailssh: take explicit ownership of stdin,stderr,stdout 2023-06-20 18:15:09 -07:00
incubator_linux.go all: update copyright and license headers 2023-01-27 15:36:29 -08:00
privs_test.go ssh/tailssh: fix privilege dropping on FreeBSD; add tests 2023-03-20 16:09:18 -04:00
tailssh.go ssh/tailssh: take explicit ownership of stdin,stderr,stdout 2023-06-20 18:15:09 -07:00
tailssh_test.go ssh/tailssh: fix regression after LDAP support 2023-05-21 07:53:25 -07:00
user.go ssh/tailssh: Max Username Length 256 for linux 2023-06-05 18:04:30 -07:00