fix version
This commit is contained in:
12
main.go
12
main.go
@@ -97,15 +97,15 @@ func handleChannel(channel ssh.Channel, requests <-chan *ssh.Request) {
|
||||
defer channel.Close()
|
||||
var ptmx *os.File
|
||||
var termWidth, termHeight uint32 = 80, 24
|
||||
var term string
|
||||
var clientTerm string
|
||||
for req := range requests {
|
||||
switch req.Type {
|
||||
case "pty-req":
|
||||
if len(req.Payload) >= 4 {
|
||||
termLen := binary.BigEndian.Uint32(req.Payload[0:4])
|
||||
if len(req.Payload) >= int(4+termLen+16) {
|
||||
term = string(req.Payload[4 : 4+termLen])
|
||||
log.Println("Client TERM:", term)
|
||||
clientTerm = string(req.Payload[4 : 4+termLen])
|
||||
log.Println("Client TERM:", clientTerm)
|
||||
cols := binary.BigEndian.Uint32(req.Payload[4+termLen : 4+termLen+4])
|
||||
rows := binary.BigEndian.Uint32(req.Payload[4+termLen+4 : 4+termLen+8])
|
||||
if cols > 0 {
|
||||
@@ -138,8 +138,8 @@ func handleChannel(channel ssh.Channel, requests <-chan *ssh.Request) {
|
||||
}
|
||||
cmd := exec.Command(command)
|
||||
envTerm := "TERM=xterm-256color"
|
||||
if term != "" {
|
||||
envTerm = "TERM=" + term
|
||||
if clientTerm != "" {
|
||||
envTerm = "TERM=" + clientTerm
|
||||
}
|
||||
cmd.Env = []string{"PATH=/bin", envTerm}
|
||||
cmd.Dir = "/"
|
||||
@@ -149,7 +149,7 @@ func handleChannel(channel ssh.Channel, requests <-chan *ssh.Request) {
|
||||
log.Println("PTY start error:", err)
|
||||
return
|
||||
}
|
||||
if err := term.MakeRaw(int(ptmx.Fd())); err != nil {
|
||||
if _, err := term.MakeRaw(int(ptmx.Fd())); err != nil {
|
||||
log.Println("MakeRaw master error:", err)
|
||||
}
|
||||
go func() {
|
||||
|
||||
Reference in New Issue
Block a user