mirror of https://gogs.blitter.com/RLabs/xs
Fixed handling of -x non-interactive command runs and hangup of interactive session
This commit is contained in:
parent
cb0ce956b9
commit
dd746cf343
|
@ -168,6 +168,7 @@ func main() {
|
|||
// exit with outerr == nil
|
||||
_, outerr := io.Copy(conn, os.Stdin)
|
||||
if outerr != nil {
|
||||
log.Println(outerr)
|
||||
if outerr.Error() != "EOF" {
|
||||
fmt.Println(outerr)
|
||||
os.Exit(2)
|
||||
|
|
|
@ -121,9 +121,9 @@ func runShellAs(who string, cmd string, interactive bool, conn hkex.Conn) (err e
|
|||
|
||||
//err = c.Run() // returns when c finishes.
|
||||
|
||||
log.Printf("[%s]\n", cmd)
|
||||
if err != nil {
|
||||
log.Printf("Command finished with error: %v", err)
|
||||
log.Printf("[%s]\n", cmd)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -314,13 +314,13 @@ func (c Conn) Read(b []byte) (n int, err error) {
|
|||
err = binary.Read(c.c, binary.BigEndian, &hmacIn)
|
||||
// Normal client 'exit' from interactive session will cause
|
||||
// (on server side) err.Error() == "<iface/addr info ...>: use of closed network connection"
|
||||
if err != nil && err.Error() != "EOF" {
|
||||
if err != nil {
|
||||
if !strings.HasSuffix(err.Error(), "use of closed network connection") {
|
||||
log.Println("unexpected Read() err:", err)
|
||||
} else {
|
||||
log.Println("[Client hung up]")
|
||||
return 0, io.EOF
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
|
||||
//if err != nil {
|
||||
|
@ -424,7 +424,8 @@ func (c Conn) Write(b []byte) (n int, err error) {
|
|||
|
||||
n, err = c.c.Write(wb.Bytes())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
//panic(err)
|
||||
log.Println(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue