Forráskód Böngészése

fix(ssh): git clone via built-in SSH server hangs (#8135)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
ᴊᴏᴇ ᴄʜᴇɴ 1 hete
szülő
commit
7ad425025e
5 módosított fájl, 26 hozzáadás és 19 törlés
  1. 4 0
      CHANGELOG.md
  2. 8 4
      internal/conf/conf.go
  3. 1 1
      internal/conf/static.go
  4. 12 13
      internal/conf/static_test.go
  5. 1 1
      internal/ssh/ssh.go

+ 4 - 0
CHANGELOG.md

@@ -4,6 +4,10 @@ All notable changes to Gogs are documented in this file.
 
 ## 0.15.0+dev (`main`)
 
+### Fixed
+
+- Git clone via the built-in SSH server hangs. [#8132](https://github.com/gogs/gogs/issues/8132)
+
 ## 0.14.0
 
 ### Added

+ 8 - 4
internal/conf/conf.go

@@ -70,7 +70,7 @@ func Init(customConf string) error {
 		if err = File.Append(customConf); err != nil {
 			return errors.Wrapf(err, "append %q", customConf)
 		}
-	} else {
+	} else if !HookMode {
 		log.Warn("Custom config %q not found. Ignore this warning if you're running for the first time", customConf)
 	}
 
@@ -142,9 +142,11 @@ func Init(customConf string) error {
 			}
 
 			if IsWindowsRuntime() || semverutil.Compare(sshVersion, "<", "5.1") {
-				log.Warn(`SSH minimum key size check is forced to be disabled because server is not eligible:
+				if !HookMode {
+					log.Warn(`SSH minimum key size check is forced to be disabled because server is not eligible:
 	1. Windows server
 	2. OpenSSH version is lower than 5.1`)
+				}
 			} else {
 				SSH.MinimumKeySizes = map[string]int{}
 				for _, key := range File.Section("ssh.minimum_key_sizes").Keys() {
@@ -346,8 +348,10 @@ func Init(customConf string) error {
 	LFS.ObjectsPath = ensureAbs(LFS.ObjectsPath)
 
 	handleDeprecated()
-	for _, warning := range checkInvalidOptions(File) {
-		log.Warn("%s", warning)
+	if !HookMode {
+		for _, warning := range checkInvalidOptions(File) {
+			log.Warn("%s", warning)
+		}
 	}
 
 	if err = File.Section("cache").MapTo(&Cache); err != nil {

+ 1 - 1
internal/conf/static.go

@@ -442,7 +442,7 @@ func checkInvalidOptions(config *ini.File) (warnings []string) {
 		"service": "auth",
 	}
 	for oldSection, newSection := range renamedSections {
-		if config.Section(oldSection).KeyStrings() != nil {
+		if len(config.Section(oldSection).KeyStrings()) > 0 {
 			warnings = append(warnings, fmt.Sprintf("section [%s] is invalid, use [%s] instead", oldSection, newSection))
 		}
 	}

+ 12 - 13
internal/conf/static_test.go

@@ -54,21 +54,20 @@ func TestCheckInvalidOptions(t *testing.T) {
 	_, _ = cfg.Section("server").NewKey("NONEXISTENT_OPTION", "true")
 
 	wantWarnings := []string{
-		"option [auth] ACTIVE_CODE_LIVE_MINUTES is invalid, use [auth] ACTIVATE_CODE_LIVES instead",
-		"option [auth] ENABLE_CAPTCHA is invalid, use [auth] ENABLE_REGISTRATION_CAPTCHA instead",
-		"option [auth] ENABLE_NOTIFY_MAIL is invalid, use [user] ENABLE_EMAIL_NOTIFICATION instead",
-		"option [auth] REGISTER_EMAIL_CONFIRM is invalid, use [auth] REQUIRE_EMAIL_CONFIRMATION instead",
-		"option [auth] RESET_PASSWD_CODE_LIVE_MINUTES is invalid, use [auth] RESET_PASSWORD_CODE_LIVES instead",
-		"option [database] DB_TYPE is invalid, use [database] TYPE instead",
-		"option [database] PASSWD is invalid, use [database] PASSWORD instead",
-		"option [security] REVERSE_PROXY_AUTHENTICATION_USER is invalid, use [auth] REVERSE_PROXY_AUTHENTICATION_HEADER instead",
-		"option [session] GC_INTERVAL_TIME is invalid, use [session] GC_INTERVAL instead",
-		"option [session] SESSION_LIFE_TIME is invalid, use [session] MAX_LIFE_TIME instead",
+		"option [auth] ACTIVE_CODE_LIVE_MINUTES is invalid",
+		"option [auth] ENABLE_CAPTCHA is invalid",
+		"option [auth] ENABLE_NOTIFY_MAIL is invalid",
+		"option [auth] REGISTER_EMAIL_CONFIRM is invalid",
+		"option [auth] RESET_PASSWD_CODE_LIVE_MINUTES is invalid",
+		"option [database] DB_TYPE is invalid",
+		"option [database] PASSWD is invalid",
+		"option [security] REVERSE_PROXY_AUTHENTICATION_USER is invalid",
+		"option [session] GC_INTERVAL_TIME is invalid",
+		"option [session] SESSION_LIFE_TIME is invalid",
 		"section [mailer] is invalid, use [email] instead",
 		"section [service] is invalid, use [auth] instead",
-		"option [server] ROOT_URL is invalid, use [server] EXTERNAL_URL instead",
-		"option [server] LANDING_PAGE is invalid, use [server] LANDING_URL instead",
-
+		"option [server] ROOT_URL is invalid",
+		"option [server] LANDING_PAGE is invalid",
 		"option [server] NONEXISTENT_OPTION is invalid",
 	}
 

+ 1 - 1
internal/ssh/ssh.go

@@ -87,6 +87,7 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) {
 					_ = req.Reply(true, nil)
 					go func() {
 						_, _ = io.Copy(input, ch)
+						input.Close()
 					}()
 					_, _ = io.Copy(ch, stdout)
 					_, _ = io.Copy(ch.Stderr(), stderr)
@@ -187,7 +188,6 @@ func setupHostKeys(appDataPath string, algorithms []string) ([]ssh.Signer, error
 				conf.SSH.KeygenPath,
 				"-t", algo,
 				"-f", keyPath,
-				"-m", "PEM",
 				"-N", run.Arg(""),
 			}
 			err = run.Cmd(context.Background(), args...).Run().Wait()