From 370f588328b1424932966c4a766706d5a2a328d9 Mon Sep 17 00:00:00 2001 From: Stefan Mayr Date: Wed, 30 Nov 2022 23:57:01 +0100 Subject: [PATCH] Do not interpret EOF as an error Feeding a tar file through ssh via stdin can result in an EOF when the file is finished which is not an error. That EOF case should not abort the session. --- ssh/connection.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ssh/connection.go b/ssh/connection.go index ee7248b19..6055c77e3 100644 --- a/ssh/connection.go +++ b/ssh/connection.go @@ -196,6 +196,11 @@ func (c Connection) runInSession(cmd string, stdout, stderr io.Writer, stdin io. } if err != nil { + // special case: EOF != ErrUnexpectedEOF. This is okay and should not abort the session + switch err { + case io.EOF: + return 0, nil + } switch err := err.(type) { case *ssh.ExitError: return err.ExitStatus(), nil