Skip to content

Commit

Permalink
ssh: ignore io.EOF from sftp.Server.Serve
Browse files Browse the repository at this point in the history
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 <joetsai@digital-static.net>
Signed-off-by: Alex Paguis <alex@windscribe.com>
  • Loading branch information
dsnet authored and alexelisenko committed Feb 15, 2024
1 parent 2029e30 commit 8b288d7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ssh/tailssh/incubator.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,12 @@ func beIncubator(args []string) error {
if err != nil {
return err
}
return server.Serve()
// TODO(https://github.com/pkg/sftp/pull/554): Revert the check for io.EOF,
// when sftp is patched to report clean termination.
if err := server.Serve(); err != nil && err != io.EOF {
return err
}
return nil
}

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

0 comments on commit 8b288d7

Please sign in to comment.