client prints nonzero remote end exit status; comment cleanup

This commit is contained in:
Russ Magee 2018-09-06 11:40:13 -07:00
parent db1b494d00
commit 8a24fb113f
2 changed files with 9 additions and 3 deletions

View file

@ -241,6 +241,9 @@ func doShellMode(isInteractive bool, conn *hkexnet.Conn, oldState *hkexsh.State,
_, inerr := io.Copy(os.Stdout, conn)
if inerr != nil {
_ = hkexsh.Restore(int(os.Stdin.Fd()), oldState) // Best effort.
// Copy operations and user logging off will cause
// a "use of closed network connection" so handle that
// gracefully here
if !strings.HasSuffix(inerr.Error(), "use of closed network connection") {
log.Println(inerr)
os.Exit(1)
@ -545,5 +548,8 @@ func main() {
_ = hkexsh.Restore(int(os.Stdin.Fd()), oldState) // Best effort.
}
if rec.status != 0 {
fmt.Fprintln(os.Stderr, "Remote end exited with status:", rec.status)
}
os.Exit(rec.status)
}

View file

@ -315,8 +315,8 @@ func runShellAs(who string, cmd string, interactive bool, conn hkexnet.Conn, cha
exitStatus = status.ExitStatus()
log.Printf("Exit Status: %d", exitStatus)
}
}
conn.SetStatus(uint8(exitStatus))
}
conn.SetStatus(uint8(exitStatus))
}
wg.Wait() // Wait on pty->stdout completion to client
}
@ -530,7 +530,7 @@ func main() {
}
hc.SetStatus(uint8(cmdStatus))
// Signal other end transfer is complete
hc.WritePacket([]byte{byte(/*255*/cmdStatus)}, hkexnet.CSOExitStatus)
hc.WritePacket([]byte{byte( /*255*/ cmdStatus)}, hkexnet.CSOExitStatus)
//fmt.Println("Waiting for EOF from other end.")
_, _ = hc.Read(nil /*ackByte*/)
//fmt.Println("Got remote end ack.")