Skip to content

Commit d6c9ed3

Browse files
committed
Fix test
1 parent 6187ce0 commit d6c9ed3

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

modules/setting/ssh.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package setting
55

66
import (
7+
"os"
78
"path/filepath"
89
"strings"
910
"text/template"
@@ -60,6 +61,7 @@ var SSH = struct {
6061
MinimumKeySizeCheck: true,
6162
MinimumKeySizes: map[string]int{"ed25519": 256, "ed25519-sk": 256, "ecdsa": 256, "ecdsa-sk": 256, "rsa": 3071},
6263
ServerHostKeys: []string{"ssh/gitea.rsa", "ssh/gogs.rsa"},
64+
KeyTestPath: "ssh_key_test",
6365
AuthorizedKeysCommandTemplate: "{{.AppPath}} --config={{.CustomConf}} serv key-{{.Key.ID}}",
6466
PerWriteTimeout: PerWriteTimeout,
6567
PerWritePerKbTimeout: PerWritePerKbTimeout,
@@ -122,10 +124,6 @@ func loadSSHFrom(rootCfg ConfigProvider) {
122124
if len(serverMACs) > 0 {
123125
SSH.ServerMACs = serverMACs
124126
}
125-
SSH.KeyTestPath = sec.Key("SSH_KEY_TEST_PATH").MustString("ssh_key_test")
126-
if !filepath.IsAbs(SSH.KeyTestPath) {
127-
SSH.KeyTestPath = filepath.Join(TempPath, SSH.KeyTestPath)
128-
}
129127
if err = sec.MapTo(&SSH); err != nil {
130128
log.Fatal("Failed to map SSH settings: %v", err)
131129
}
@@ -135,6 +133,15 @@ func loadSSHFrom(rootCfg ConfigProvider) {
135133
}
136134
}
137135

136+
SSH.KeyTestPath = sec.Key("SSH_KEY_TEST_PATH").MustString("ssh_key_test")
137+
if !filepath.IsAbs(SSH.KeyTestPath) {
138+
SSH.KeyTestPath = filepath.Join(TempPath, SSH.KeyTestPath)
139+
}
140+
// FIXME: why 0o644 for a directory .....
141+
if err := os.MkdirAll(SSH.KeyTestPath, 0o644); err != nil {
142+
log.Fatal("failed to create directory %q for ssh key test: %w", SSH.KeyTestPath, err)
143+
}
144+
138145
SSH.KeygenPath = sec.Key("SSH_KEYGEN_PATH").String()
139146
SSH.Port = sec.Key("SSH_PORT").MustInt(22)
140147
SSH.ListenPort = sec.Key("SSH_LISTEN_PORT").MustInt(SSH.Port)

modules/ssh/init.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ func Init() error {
3232

3333
builtinUnused()
3434

35-
// FIXME: why 0o644 for a directory .....
36-
if err := os.MkdirAll(setting.SSH.KeyTestPath, 0o644); err != nil {
37-
return fmt.Errorf("failed to create directory %q for ssh key test: %w", setting.SSH.KeyTestPath, err)
38-
}
39-
4035
if len(setting.SSH.TrustedUserCAKeys) > 0 && setting.SSH.AuthorizedPrincipalsEnabled {
4136
caKeysFileName := setting.SSH.TrustedUserCAKeysFile
4237
caKeysFileDir := filepath.Dir(caKeysFileName)

0 commit comments

Comments
 (0)