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 #8592

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
(cherry picked from commit bb4b35e)
  • Loading branch information
dsnet authored and bradfitz committed Jul 21, 2023
1 parent b1cc883 commit 0d2a69a
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 0d2a69a

Please sign in to comment.