diff options
author | Gusted <williamzijl7@hotmail.com> | 2022-08-02 09:56:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-02 15:56:38 +0800 |
commit | 8740631b79390299e0dc82469bcb85553a4a09f7 (patch) | |
tree | 24bdd73e081a3457eae7bc34d3f23f3b9e322f79 /modules | |
parent | 036dd8a788468e7730b29982747cc3cf8829ce86 (diff) | |
download | gitea-8740631b79390299e0dc82469bcb85553a4a09f7.tar.gz gitea-8740631b79390299e0dc82469bcb85553a4a09f7.zip |
Enable Wire 2 for Internal SSH Server (#20616)
- Git only decides to use the Wire 2 protocol when `git
{receive,upload}-pack` receive the `GIT_PROTOCOL` environment with as
value `version=2`. Currently the internal SSH Server wasn't passing this
environment through. The `gitea serv` code already passed all received
environments to the git command, so no code changes there.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/ssh/ssh.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go index bffe29f4c3..5cc011e581 100644 --- a/modules/ssh/ssh.go +++ b/modules/ssh/ssh.go @@ -75,11 +75,21 @@ func sessionHandler(session ssh.Session) { ctx, cancel := context.WithCancel(session.Context()) defer cancel() + gitProtocol := "" + for _, env := range session.Environ() { + if strings.HasPrefix(env, "GIT_PROTOCOL=") { + // The value would be version=2, so using normal split doesn't work here. + gitProtocol = strings.SplitN(env, "=", 2)[1] + break + } + } + cmd := exec.CommandContext(ctx, setting.AppPath, args...) cmd.Env = append( os.Environ(), "SSH_ORIGINAL_COMMAND="+command, "SKIP_MINWINSVC=1", + "GIT_PROTOCOL="+gitProtocol, ) stdout, err := cmd.StdoutPipe() |