]> source.dussan.org Git - gitea.git/commitdiff
Fix admin queue page title (#26409)
authorwxiaoguang <wxiaoguang@gmail.com>
Thu, 10 Aug 2023 02:05:37 +0000 (10:05 +0800)
committerGitHub <noreply@github.com>
Thu, 10 Aug 2023 02:05:37 +0000 (02:05 +0000)
Fix #26408

```
# locale_en-US.ini
[admin]
monitor.queues = Queues
```

---------

Co-authored-by: silverwind <me@silverwind.io>
modules/ssh/ssh.go
routers/web/admin/queue.go
tests/test_utils.go

index 923fa51d228a7206b2b55d5b78b6b45dea224b38..a5af5c129b8b84707f3fd08a10cd10329c551bec 100644 (file)
@@ -17,6 +17,7 @@ import (
        "os"
        "os/exec"
        "path/filepath"
+       "reflect"
        "strconv"
        "strings"
        "sync"
@@ -164,6 +165,10 @@ func sessionHandler(session ssh.Session) {
 }
 
 func publicKeyHandler(ctx ssh.Context, key ssh.PublicKey) bool {
+       // FIXME: the "ssh.Context" is not thread-safe, so db operations should use the immutable parent "Context"
+       // TODO: Remove after https://github.com/gliderlabs/ssh/pull/211
+       parentCtx := reflect.ValueOf(ctx).Elem().FieldByName("Context").Interface().(context.Context)
+
        if log.IsDebug() { // <- FingerprintSHA256 is kinda expensive so only calculate it if necessary
                log.Debug("Handle Public Key: Fingerprint: %s from %s", gossh.FingerprintSHA256(key), ctx.RemoteAddr())
        }
@@ -189,7 +194,7 @@ func publicKeyHandler(ctx ssh.Context, key ssh.PublicKey) bool {
                // look for the exact principal
        principalLoop:
                for _, principal := range cert.ValidPrincipals {
-                       pkey, err := asymkey_model.SearchPublicKeyByContentExact(ctx, principal)
+                       pkey, err := asymkey_model.SearchPublicKeyByContentExact(parentCtx, principal)
                        if err != nil {
                                if asymkey_model.IsErrKeyNotExist(err) {
                                        log.Debug("Principal Rejected: %s Unknown Principal: %s", ctx.RemoteAddr(), principal)
@@ -246,7 +251,7 @@ func publicKeyHandler(ctx ssh.Context, key ssh.PublicKey) bool {
                log.Debug("Handle Public Key: %s Fingerprint: %s is not a certificate", ctx.RemoteAddr(), gossh.FingerprintSHA256(key))
        }
 
-       pkey, err := asymkey_model.SearchPublicKeyByContent(ctx, strings.TrimSpace(string(gossh.MarshalAuthorizedKey(key))))
+       pkey, err := asymkey_model.SearchPublicKeyByContent(parentCtx, strings.TrimSpace(string(gossh.MarshalAuthorizedKey(key))))
        if err != nil {
                if asymkey_model.IsErrKeyNotExist(err) {
                        log.Warn("Unknown public key: %s from %s", gossh.FingerprintSHA256(key), ctx.RemoteAddr())
index 4e01846ba8baba44b30eb3255e585e05fe78ca71..18a8d7d3e6834c99ab750da3560fedc9611901e2 100644 (file)
@@ -16,7 +16,7 @@ func Queues(ctx *context.Context) {
        if !setting.IsProd {
                initTestQueueOnce()
        }
-       ctx.Data["Title"] = ctx.Tr("admin.monitor.queue")
+       ctx.Data["Title"] = ctx.Tr("admin.monitor.queues")
        ctx.Data["PageIsAdminMonitorQueue"] = true
        ctx.Data["Queues"] = queue.GetManager().ManagedQueues()
        ctx.HTML(http.StatusOK, tplQueue)
index 3bcd872d6c245dc09d6efa3917d301f4d40597bf..6ac61db63e054e763e0740b314504c7bdc3a594a 100644 (file)
@@ -12,7 +12,6 @@ import (
        "path"
        "path/filepath"
        "testing"
-       "time"
 
        "code.gitea.io/gitea/models/db"
        packages_model "code.gitea.io/gitea/models/packages"
@@ -44,8 +43,8 @@ func InitTest(requireGitea bool) {
                exitf("Environment variable $GITEA_ROOT not set")
        }
 
-       // Speedup tests that rely on the event source ticker.
-       setting.UI.Notification.EventSourceUpdateTime = time.Second
+       // TODO: Speedup tests that rely on the event source ticker, confirm whether there is any bug or failure.
+       // setting.UI.Notification.EventSourceUpdateTime = time.Second
 
        setting.IsInTesting = true
        setting.AppWorkPath = giteaRoot