mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 03:18:24 +00:00 
			
		
		
		
	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.
			
			
This commit is contained in:
		| @@ -75,11 +75,21 @@ func sessionHandler(session ssh.Session) { | |||||||
| 	ctx, cancel := context.WithCancel(session.Context()) | 	ctx, cancel := context.WithCancel(session.Context()) | ||||||
| 	defer cancel() | 	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 := exec.CommandContext(ctx, setting.AppPath, args...) | ||||||
| 	cmd.Env = append( | 	cmd.Env = append( | ||||||
| 		os.Environ(), | 		os.Environ(), | ||||||
| 		"SSH_ORIGINAL_COMMAND="+command, | 		"SSH_ORIGINAL_COMMAND="+command, | ||||||
| 		"SKIP_MINWINSVC=1", | 		"SKIP_MINWINSVC=1", | ||||||
|  | 		"GIT_PROTOCOL="+gitProtocol, | ||||||
| 	) | 	) | ||||||
|  |  | ||||||
| 	stdout, err := cmd.StdoutPipe() | 	stdout, err := cmd.StdoutPipe() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user