Skip to content

Commit bb4b35e

Browse files
dsnetbradfitz
authored andcommitted
ssh: ignore io.EOF from sftp.Server.Serve
If the connection provided to sftp.NewServer is closed, Serve returns the io.EOF error verbatim from io.Reader.Read. This is an odd error since this is an expected situation, so we manually ignore io.EOF. This is somewhat buggy since the sftp package itself incorrectly reports io.EOF in cases where it should actually be reporting io.ErrUnexpectedEOF. See pkg/sftp#554 which patches Serve to return nil on clean closes and fixes buggy uses of io.ReadFull. Fixes tailscale#8592 Signed-off-by: Joe Tsai <[email protected]>
1 parent 88cc0ad commit bb4b35e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ssh/tailssh/incubator.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,12 @@ func beIncubator(args []string) error {
270270
if err != nil {
271271
return err
272272
}
273-
return server.Serve()
273+
// TODO(https://github.com/pkg/sftp/pull/554): Revert the check for io.EOF,
274+
// when sftp is patched to report clean termination.
275+
if err := server.Serve(); err != nil && err != io.EOF {
276+
return err
277+
}
278+
return nil
274279
}
275280

276281
cmd := exec.Command(ia.cmdName, ia.cmdArgs...)

0 commit comments

Comments
 (0)