Browse Source

ignore invalid env

pull/2166/head
Bruno 9 years ago
parent
commit
1504b226a3
  1. 7
      modules/ssh/ssh.go

7
modules/ssh/ssh.go

@ -52,15 +52,16 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) {
switch req.Type { switch req.Type {
case "env": case "env":
args := strings.Split(strings.Replace(payload, "\x00", "", -1), "\v") args := strings.Split(strings.Replace(payload, "\x00", "", -1), "\v")
if len(args) != 2 { if len(args) == 2 {
return
}
args[0] = strings.TrimLeft(args[0], "\x04") args[0] = strings.TrimLeft(args[0], "\x04")
_, _, err := com.ExecCmdBytes("env", args[0]+"="+args[1]) _, _, err := com.ExecCmdBytes("env", args[0]+"="+args[1])
if err != nil { if err != nil {
log.Error(3, "env: %v", err) log.Error(3, "env: %v", err)
return return
} }
} else {
log.Info("Invalid env arguments: '%#v'", args)
}
case "exec": case "exec":
cmdName := strings.TrimLeft(payload, "'()") cmdName := strings.TrimLeft(payload, "'()")
os.Setenv("SSH_ORIGINAL_COMMAND", cmdName) os.Setenv("SSH_ORIGINAL_COMMAND", cmdName)

Loading…
Cancel
Save