Fix single command ssh exec (#483)

This commit is contained in:
Nate Brown authored and GitHub committed 2021-06-07 17:06:59 -05:00
1 parent d13f4b5948
commit c726d20578
3 files changed
+29 -4

No files matched your search

+11 -4
View File
@@ -81,11 +81,18 @@ func (s *session) handleRequests(in <-chan *ssh.Request, channel ssh.Channel) {
case "exec":
var payload = struct{ Value string }{}
cErr := ssh.Unmarshal(req.Payload, &payload)
if cErr == nil {
s.dispatchCommand(payload.Value, &stringWriter{channel})
} else {
//TODO: log it
if cErr != nil {
req.Reply(false, nil)
return
}
req.Reply(true, nil)
s.dispatchCommand(payload.Value, &stringWriter{channel})
//TODO: Fix error handling and report the proper status back
status := struct{ Status uint32 }{uint32(0)}
//TODO: I think this is how we shut down a shell as well?
channel.SendRequest("exit-status", false, ssh.Marshal(status))
channel.Close()
return