Skip to content

Commit 6d42e52

Browse files
committed
Merge remote-tracking branch 'upstream/release/v1.17' into codeberg-1.17
2 parents c626223 + 26f4fe2 commit 6d42e52

File tree

13 files changed

+80
-43
lines changed

13 files changed

+80
-43
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ require (
8585
github.com/urfave/cli v1.22.9
8686
github.com/xanzy/go-gitlab v0.64.0
8787
github.com/yohcop/openid-go v1.0.0
88-
github.com/yuin/goldmark v1.4.12
88+
github.com/yuin/goldmark v1.4.13
8989
github.com/yuin/goldmark-highlighting v0.0.0-20220208100518-594be1970594
9090
github.com/yuin/goldmark-meta v1.1.0
9191
go.jolheiser.com/hcaptcha v0.0.4

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,8 +1540,8 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
15401540
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
15411541
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
15421542
github.com/yuin/goldmark v1.4.5/go.mod h1:rmuwmfZ0+bvzB24eSC//bk1R1Zp3hM0OXYv/G2LIilg=
1543-
github.com/yuin/goldmark v1.4.12 h1:6hffw6vALvEDqJ19dOJvJKOoAOKe4NDaTqvd2sktGN0=
1544-
github.com/yuin/goldmark v1.4.12/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
1543+
github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
1544+
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
15451545
github.com/yuin/goldmark-highlighting v0.0.0-20220208100518-594be1970594 h1:yHfZyN55+5dp1wG7wDKv8HQ044moxkyGq12KFFMFDxg=
15461546
github.com/yuin/goldmark-highlighting v0.0.0-20220208100518-594be1970594/go.mod h1:U9ihbh+1ZN7fR5Se3daSPoz1CGF9IYtSvWwVQtnzGHU=
15471547
github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc=

models/perm/access/access.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,13 @@ func updateUserAccess(accessMap map[int64]*userAccess, user *user_model.User, mo
8686
// FIXME: do cross-comparison so reduce deletions and additions to the minimum?
8787
func refreshAccesses(ctx context.Context, repo *repo_model.Repository, accessMap map[int64]*userAccess) (err error) {
8888
minMode := perm.AccessModeRead
89-
if !repo.IsPrivate {
89+
if err := repo.GetOwner(ctx); err != nil {
90+
return fmt.Errorf("GetOwner: %v", err)
91+
}
92+
93+
// If the repo isn't private and isn't owned by a organization,
94+
// increase the minMode to Write.
95+
if !repo.IsPrivate && !repo.Owner.IsOrganization() {
9096
minMode = perm.AccessModeWrite
9197
}
9298

modules/setting/setting.go

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -844,16 +844,17 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
844844
SSH.StartBuiltinServer = false
845845
}
846846

847-
trustedUserCaKeys := sec.Key("SSH_TRUSTED_USER_CA_KEYS").Strings(",")
848-
for _, caKey := range trustedUserCaKeys {
847+
SSH.TrustedUserCAKeysFile = sec.Key("SSH_TRUSTED_USER_CA_KEYS_FILENAME").MustString(filepath.Join(SSH.RootPath, "gitea-trusted-user-ca-keys.pem"))
848+
849+
for _, caKey := range SSH.TrustedUserCAKeys {
849850
pubKey, _, _, _, err := gossh.ParseAuthorizedKey([]byte(caKey))
850851
if err != nil {
851852
log.Fatal("Failed to parse TrustedUserCaKeys: %s %v", caKey, err)
852853
}
853854

854855
SSH.TrustedUserCAKeysParsed = append(SSH.TrustedUserCAKeysParsed, pubKey)
855856
}
856-
if len(trustedUserCaKeys) > 0 {
857+
if len(SSH.TrustedUserCAKeys) > 0 {
857858
// Set the default as email,username otherwise we can leave it empty
858859
sec.Key("SSH_AUTHORIZED_PRINCIPALS_ALLOW").MustString("username,email")
859860
} else {
@@ -862,22 +863,6 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
862863

863864
SSH.AuthorizedPrincipalsAllow, SSH.AuthorizedPrincipalsEnabled = parseAuthorizedPrincipalsAllow(sec.Key("SSH_AUTHORIZED_PRINCIPALS_ALLOW").Strings(","))
864865

865-
if !SSH.Disabled && !SSH.StartBuiltinServer {
866-
if err := os.MkdirAll(SSH.RootPath, 0o700); err != nil {
867-
log.Fatal("Failed to create '%s': %v", SSH.RootPath, err)
868-
} else if err = os.MkdirAll(SSH.KeyTestPath, 0o644); err != nil {
869-
log.Fatal("Failed to create '%s': %v", SSH.KeyTestPath, err)
870-
}
871-
872-
if len(trustedUserCaKeys) > 0 && SSH.AuthorizedPrincipalsEnabled {
873-
fname := sec.Key("SSH_TRUSTED_USER_CA_KEYS_FILENAME").MustString(filepath.Join(SSH.RootPath, "gitea-trusted-user-ca-keys.pem"))
874-
if err := os.WriteFile(fname,
875-
[]byte(strings.Join(trustedUserCaKeys, "\n")), 0o600); err != nil {
876-
log.Fatal("Failed to create '%s': %v", fname, err)
877-
}
878-
}
879-
}
880-
881866
SSH.MinimumKeySizeCheck = sec.Key("MINIMUM_KEY_SIZE_CHECK").MustBool(SSH.MinimumKeySizeCheck)
882867
minimumKeySizes := Cfg.Section("ssh.minimum_key_sizes").Keys()
883868
for _, key := range minimumKeySizes {

modules/ssh/init.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package ssh
6+
7+
import (
8+
"fmt"
9+
"net"
10+
"os"
11+
"path/filepath"
12+
"strconv"
13+
"strings"
14+
15+
"code.gitea.io/gitea/modules/log"
16+
"code.gitea.io/gitea/modules/setting"
17+
)
18+
19+
func Init() error {
20+
if setting.SSH.Disabled {
21+
return nil
22+
}
23+
24+
if setting.SSH.StartBuiltinServer {
25+
Listen(setting.SSH.ListenHost, setting.SSH.ListenPort, setting.SSH.ServerCiphers, setting.SSH.ServerKeyExchanges, setting.SSH.ServerMACs)
26+
log.Info("SSH server started on %s. Cipher list (%v), key exchange algorithms (%v), MACs (%v)",
27+
net.JoinHostPort(setting.SSH.ListenHost, strconv.Itoa(setting.SSH.ListenPort)),
28+
setting.SSH.ServerCiphers, setting.SSH.ServerKeyExchanges, setting.SSH.ServerMACs,
29+
)
30+
return nil
31+
}
32+
33+
builtinUnused()
34+
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+
40+
if len(setting.SSH.TrustedUserCAKeys) > 0 && setting.SSH.AuthorizedPrincipalsEnabled {
41+
caKeysFileName := setting.SSH.TrustedUserCAKeysFile
42+
caKeysFileDir := filepath.Dir(caKeysFileName)
43+
44+
err := os.MkdirAll(caKeysFileDir, 0o700) // SSH.RootPath by default (That is `~/.ssh` in most cases)
45+
if err != nil {
46+
return fmt.Errorf("failed to create directory %q for ssh trusted ca keys: %w", caKeysFileDir, err)
47+
}
48+
49+
if err := os.WriteFile(caKeysFileName, []byte(strings.Join(setting.SSH.TrustedUserCAKeys, "\n")), 0o600); err != nil {
50+
return fmt.Errorf("failed to write ssh trusted ca keys to %q: %w", caKeysFileName, err)
51+
}
52+
}
53+
54+
return nil
55+
}

modules/ssh/ssh_graceful.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func listen(server *ssh.Server) {
2929
log.Info("SSH Listener: %s Closed", server.Addr)
3030
}
3131

32-
// Unused informs our cleanup routine that we will not be using a ssh port
33-
func Unused() {
32+
// builtinUnused informs our cleanup routine that we will not be using a ssh port
33+
func builtinUnused() {
3434
graceful.GetManager().InformCleanup()
3535
}

routers/api/v1/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ func Routes() *web.Route {
10101010
}, mustAllowPulls, reqRepoReader(unit.TypeCode), context.ReferencesGitRepo())
10111011
m.Group("/statuses", func() {
10121012
m.Combo("/{sha}").Get(repo.GetCommitStatuses).
1013-
Post(reqToken(), bind(api.CreateStatusOption{}), repo.NewCommitStatus)
1013+
Post(reqToken(), reqRepoWriter(unit.TypeCode), bind(api.CreateStatusOption{}), repo.NewCommitStatus)
10141014
}, reqRepoReader(unit.TypeCode))
10151015
m.Group("/commits", func() {
10161016
m.Get("", context.ReferencesGitRepo(), repo.GetAllCommits)

routers/init.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ package routers
66

77
import (
88
"context"
9-
"net"
109
"reflect"
1110
"runtime"
12-
"strconv"
1311

1412
"code.gitea.io/gitea/models"
1513
asymkey_model "code.gitea.io/gitea/models/asymkey"
@@ -158,14 +156,8 @@ func GlobalInitInstalled(ctx context.Context) {
158156

159157
mustInitCtx(ctx, syncAppPathForGit)
160158

161-
if setting.SSH.StartBuiltinServer {
162-
ssh.Listen(setting.SSH.ListenHost, setting.SSH.ListenPort, setting.SSH.ServerCiphers, setting.SSH.ServerKeyExchanges, setting.SSH.ServerMACs)
163-
log.Info("SSH server started on %s. Cipher list (%v), key exchange algorithms (%v), MACs (%v)",
164-
net.JoinHostPort(setting.SSH.ListenHost, strconv.Itoa(setting.SSH.ListenPort)),
165-
setting.SSH.ServerCiphers, setting.SSH.ServerKeyExchanges, setting.SSH.ServerMACs)
166-
} else {
167-
ssh.Unused()
168-
}
159+
mustInit(ssh.Init)
160+
169161
auth.Init()
170162
svg.Init()
171163
}

services/migrations/gitea_uploader.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package migrations
77

88
import (
99
"context"
10-
"errors"
1110
"fmt"
1211
"io"
1312
"os"
@@ -268,7 +267,7 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
268267
// calc NumCommits if possible
269268
if rel.TagName != "" {
270269
commit, err := g.gitRepo.GetTagCommit(rel.TagName)
271-
if !errors.Is(err, git.ErrNotExist{}) {
270+
if !git.IsErrNotExist(err) {
272271
if err != nil {
273272
return fmt.Errorf("GetTagCommit[%v]: %v", rel.TagName, err)
274273
}

web_src/less/_admin.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
.table.segment {
1313
padding: 0;
1414
font-size: 13px;
15-
overflow-x: scroll;
15+
overflow-x: auto;
1616

1717
&:not(.striped) {
1818
thead {

web_src/less/_repository.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3352,7 +3352,7 @@ td.blob-excerpt {
33523352
.commit-header-row {
33533353
.ui.horizontal.list {
33543354
width: 100%;
3355-
overflow-x: scroll;
3355+
overflow-x: auto;
33563356
margin-top: 2px;
33573357

33583358
.item {
@@ -3401,7 +3401,7 @@ td.blob-excerpt {
34013401
}
34023402

34033403
.commit-table {
3404-
overflow-x: scroll;
3404+
overflow-x: auto;
34053405

34063406
td.sha,
34073407
th.sha {

web_src/less/_user.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,5 @@
170170
}
171171

172172
#notification_div .tab.segment {
173-
overflow-x: scroll;
173+
overflow-x: auto;
174174
}

web_src/less/features/gitgraph.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#git-graph-container {
2-
overflow-x: scroll;
2+
overflow-x: auto;
33
width: 100%;
44
min-height: 350px;
55

0 commit comments

Comments
 (0)