Skip to content

Commit 8ad331c

Browse files
authored
Fix admin queue page title and fix CI failures (#26409) (#26421)
Backport #26409 * Fix #26408 * Bypass the data race issue in "ssh" package
1 parent dbabdf6 commit 8ad331c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

modules/ssh/ssh.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"os"
1818
"os/exec"
1919
"path/filepath"
20+
"reflect"
2021
"strconv"
2122
"strings"
2223
"sync"
@@ -164,6 +165,10 @@ func sessionHandler(session ssh.Session) {
164165
}
165166

166167
func publicKeyHandler(ctx ssh.Context, key ssh.PublicKey) bool {
168+
// FIXME: the "ssh.Context" is not thread-safe, so db operations should use the immutable parent "Context"
169+
// TODO: Remove after https://github.com/gliderlabs/ssh/pull/211
170+
parentCtx := reflect.ValueOf(ctx).Elem().FieldByName("Context").Interface().(context.Context)
171+
167172
if log.IsDebug() { // <- FingerprintSHA256 is kinda expensive so only calculate it if necessary
168173
log.Debug("Handle Public Key: Fingerprint: %s from %s", gossh.FingerprintSHA256(key), ctx.RemoteAddr())
169174
}
@@ -189,7 +194,7 @@ func publicKeyHandler(ctx ssh.Context, key ssh.PublicKey) bool {
189194
// look for the exact principal
190195
principalLoop:
191196
for _, principal := range cert.ValidPrincipals {
192-
pkey, err := asymkey_model.SearchPublicKeyByContentExact(ctx, principal)
197+
pkey, err := asymkey_model.SearchPublicKeyByContentExact(parentCtx, principal)
193198
if err != nil {
194199
if asymkey_model.IsErrKeyNotExist(err) {
195200
log.Debug("Principal Rejected: %s Unknown Principal: %s", ctx.RemoteAddr(), principal)
@@ -246,7 +251,7 @@ func publicKeyHandler(ctx ssh.Context, key ssh.PublicKey) bool {
246251
log.Debug("Handle Public Key: %s Fingerprint: %s is not a certificate", ctx.RemoteAddr(), gossh.FingerprintSHA256(key))
247252
}
248253

249-
pkey, err := asymkey_model.SearchPublicKeyByContent(ctx, strings.TrimSpace(string(gossh.MarshalAuthorizedKey(key))))
254+
pkey, err := asymkey_model.SearchPublicKeyByContent(parentCtx, strings.TrimSpace(string(gossh.MarshalAuthorizedKey(key))))
250255
if err != nil {
251256
if asymkey_model.IsErrKeyNotExist(err) {
252257
log.Warn("Unknown public key: %s from %s", gossh.FingerprintSHA256(key), ctx.RemoteAddr())

routers/web/admin/queue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func Queues(ctx *context.Context) {
1616
if !setting.IsProd {
1717
initTestQueueOnce()
1818
}
19-
ctx.Data["Title"] = ctx.Tr("admin.monitor.queue")
19+
ctx.Data["Title"] = ctx.Tr("admin.monitor.queues")
2020
ctx.Data["PageIsAdminMonitorQueue"] = true
2121
ctx.Data["Queues"] = queue.GetManager().ManagedQueues()
2222
ctx.HTML(http.StatusOK, tplQueue)

0 commit comments

Comments
 (0)