Skip to content

Commit 8740631

Browse files
author
Gusted
authored
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.
1 parent 036dd8a commit 8740631

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

modules/ssh/ssh.go

+10
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,21 @@ func sessionHandler(session ssh.Session) {
7575
ctx, cancel := context.WithCancel(session.Context())
7676
defer cancel()
7777

78+
gitProtocol := ""
79+
for _, env := range session.Environ() {
80+
if strings.HasPrefix(env, "GIT_PROTOCOL=") {
81+
// The value would be version=2, so using normal split doesn't work here.
82+
gitProtocol = strings.SplitN(env, "=", 2)[1]
83+
break
84+
}
85+
}
86+
7887
cmd := exec.CommandContext(ctx, setting.AppPath, args...)
7988
cmd.Env = append(
8089
os.Environ(),
8190
"SSH_ORIGINAL_COMMAND="+command,
8291
"SKIP_MINWINSVC=1",
92+
"GIT_PROTOCOL="+gitProtocol,
8393
)
8494

8595
stdout, err := cmd.StdoutPipe()

0 commit comments

Comments
 (0)