From 9e09e4850283b2b521f6087418d5d165bcc7cf8f Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 18 Mar 2016 06:13:16 -0400 Subject: #2850 fix potential SSH commands dislocation When use builtin SSH server with concurrent operations, there are probabilities One connection could use the command from another connections. Fix this by set SSH_ORIGINAL_COMMAND for each command, not set in global scope. --- modules/ssh/ssh.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/ssh') diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go index 18313d1ef8..ceecc9bbfc 100644 --- a/modules/ssh/ssh.go +++ b/modules/ssh/ssh.go @@ -62,12 +62,12 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) { } case "exec": cmdName := strings.TrimLeft(payload, "'()") - os.Setenv("SSH_ORIGINAL_COMMAND", cmdName) log.Trace("SSH: Payload: %v", cmdName) args := []string{"serv", "key-" + keyID, "--config=" + setting.CustomConf} log.Trace("SSH: Arguments: %v", args) cmd := exec.Command(setting.AppPath, args...) + cmd.Env = append(os.Environ(), "SSH_ORIGINAL_COMMAND="+cmdName) stdout, err := cmd.StdoutPipe() if err != nil { -- cgit v1.2.3