summaryrefslogtreecommitdiffstats
path: root/modules/ssh
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-03-18 06:13:16 -0400
committerUnknwon <u@gogs.io>2016-03-18 06:13:16 -0400
commit9e09e4850283b2b521f6087418d5d165bcc7cf8f (patch)
treede37a9598d3ab094127089c56ce4895dd8fb01b5 /modules/ssh
parentc79774e8d48faed4a04be80eb0ede3fbc4276d4a (diff)
downloadgitea-9e09e4850283b2b521f6087418d5d165bcc7cf8f.tar.gz
gitea-9e09e4850283b2b521f6087418d5d165bcc7cf8f.zip
#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.
Diffstat (limited to 'modules/ssh')
-rw-r--r--modules/ssh/ssh.go2
1 files changed, 1 insertions, 1 deletions
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 {