|
|
@ -217,10 +217,13 @@ func (sc *Server) handleSession(newch ssh.NewChannel) {
|
|
|
|
case "shell":
|
|
|
|
case "shell":
|
|
|
|
ret = true
|
|
|
|
ret = true
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
|
|
|
|
env = append(env, fmt.Sprintf("SHELL=powershell"))
|
|
|
|
cmd = exec.Command("powershell")
|
|
|
|
cmd = exec.Command("powershell")
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
cmd = exec.Command("bash", "-l")
|
|
|
|
env = append(env, fmt.Sprintf("SHELL=/bin/bash"))
|
|
|
|
|
|
|
|
cmd = exec.Command("/bin/bash", "-l")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
env = append(env, fmt.Sprintf("HOME=/home/guest"))
|
|
|
|
cmd.Env = env
|
|
|
|
cmd.Env = env
|
|
|
|
go handleShell(cmd, ch, _console, ptsname)
|
|
|
|
go handleShell(cmd, ch, _console, ptsname)
|
|
|
|
case "signal":
|
|
|
|
case "signal":
|
|
|
@ -231,10 +234,13 @@ func (sc *Server) handleSession(newch ssh.NewChannel) {
|
|
|
|
if err = ssh.Unmarshal(r.Payload, &_cmd); err == nil {
|
|
|
|
if err = ssh.Unmarshal(r.Payload, &_cmd); err == nil {
|
|
|
|
log.Infoln("execute command", _cmd.Arg)
|
|
|
|
log.Infoln("execute command", _cmd.Arg)
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
|
|
|
|
env = append(env, fmt.Sprintf("SHELL=powershell"))
|
|
|
|
cmd = exec.Command("powershell", "-Command", _cmd.Arg)
|
|
|
|
cmd = exec.Command("powershell", "-Command", _cmd.Arg)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
cmd = exec.Command("bash", "-c", _cmd.Arg)
|
|
|
|
env = append(env, fmt.Sprintf("SHELL=/bin/bash"))
|
|
|
|
|
|
|
|
cmd = exec.Command("/bin/bash", "-c", _cmd.Arg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
env = append(env, fmt.Sprintf("HOME=/home/guest"))
|
|
|
|
cmd.Env = env
|
|
|
|
cmd.Env = env
|
|
|
|
//cmd.Stdin = ch
|
|
|
|
//cmd.Stdin = ch
|
|
|
|
go handleCommand(cmd, ch)
|
|
|
|
go handleCommand(cmd, ch)
|
|
|
@ -261,6 +267,7 @@ func (sc *Server) handleSession(newch ssh.NewChannel) {
|
|
|
|
log.Errorln(err)
|
|
|
|
log.Errorln(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
env = append(env, fmt.Sprintf("SSH_TTY=%s", ptsname))
|
|
|
|
env = append(env, fmt.Sprintf("SSH_TTY=%s", ptsname))
|
|
|
|
|
|
|
|
env = append(env, fmt.Sprintf("TERM=%s", _ptyReq.Term))
|
|
|
|
ws, err := _console.Size()
|
|
|
|
ws, err := _console.Size()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Errorln(err)
|
|
|
|
log.Errorln(err)
|
|
|
|