Skip to content

Commit 7cd5cad

Browse files
committed
Merge remote-tracking branch 'origin/master' into fix-13175-switch-to-report-errors-on-checking-exists
2 parents 880c52b + 5626811 commit 7cd5cad

32 files changed

+560
-846
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This changelog goes through all the changes that have been made in each release
44
without substantial changes to our git log; to see the highlights of what has
55
been added to each release, please refer to the [blog](https://blog.gitea.io).
66

7-
## [1.13.0-RC1](https://github.com/go-gitea/gitea/releases/tag/v1.13.0-RC1) - 2020-10-14
7+
## [1.13.0-RC1](https://github.com/go-gitea/gitea/releases/tag/v1.13.0-rc1) - 2020-10-14
88

99
* SECURITY
1010
* Mitigate Security vulnerability in the git hook feature (#13058)

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ Mura Li <[email protected]> (@typeless)
3737
jaqra <[email protected]> (@jaqra)
3838
David Svantesson <[email protected]> (@davidsvantesson)
3939
CirnoT <[email protected]> (@CirnoT)
40+
a1012112796 <[email protected]> (@a1012112796)

cmd/web.go

Lines changed: 93 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"code.gitea.io/gitea/routers"
2121
"code.gitea.io/gitea/routers/routes"
2222

23+
"gitea.com/macaron/macaron"
24+
2325
context2 "github.com/gorilla/context"
2426
"github.com/urfave/cli"
2527
"golang.org/x/crypto/acme/autocert"
@@ -114,52 +116,93 @@ func runWeb(ctx *cli.Context) error {
114116
setting.WritePIDFile = true
115117
}
116118

119+
// Flag for port number in case first time run conflict.
120+
if ctx.IsSet("port") {
121+
if err := setPort(ctx.String("port")); err != nil {
122+
return err
123+
}
124+
}
125+
126+
// Perform pre-initialization
127+
needsInstall := routers.PreInstallInit(graceful.GetManager().HammerContext())
128+
if needsInstall {
129+
m := routes.NewMacaron()
130+
routes.RegisterInstallRoute(m)
131+
err := listen(m, false)
132+
select {
133+
case <-graceful.GetManager().IsShutdown():
134+
<-graceful.GetManager().Done()
135+
log.Info("PID: %d Gitea Web Finished", os.Getpid())
136+
log.Close()
137+
return err
138+
default:
139+
}
140+
} else {
141+
NoInstallListener()
142+
}
143+
144+
if setting.EnablePprof {
145+
go func() {
146+
log.Info("Starting pprof server on localhost:6060")
147+
log.Info("%v", http.ListenAndServe("localhost:6060", nil))
148+
}()
149+
}
150+
151+
log.Info("Global init")
117152
// Perform global initialization
118153
routers.GlobalInit(graceful.GetManager().HammerContext())
119154

120155
// Set up Macaron
121156
m := routes.NewMacaron()
122157
routes.RegisterRoutes(m)
123158

124-
// Flag for port number in case first time run conflict.
125-
if ctx.IsSet("port") {
126-
setting.AppURL = strings.Replace(setting.AppURL, setting.HTTPPort, ctx.String("port"), 1)
127-
setting.HTTPPort = ctx.String("port")
159+
err := listen(m, true)
160+
<-graceful.GetManager().Done()
161+
log.Info("PID: %d Gitea Web Finished", os.Getpid())
162+
log.Close()
163+
return err
164+
}
128165

129-
switch setting.Protocol {
130-
case setting.UnixSocket:
131-
case setting.FCGI:
132-
case setting.FCGIUnix:
133-
default:
134-
// Save LOCAL_ROOT_URL if port changed
135-
cfg := ini.Empty()
136-
isFile, err := util.IsFile(setting.CustomConf)
137-
if err != nil {
138-
log.Fatal("Unable to check if %s is a file", err)
139-
}
140-
if isFile {
141-
// Keeps custom settings if there is already something.
142-
if err := cfg.Append(setting.CustomConf); err != nil {
143-
return fmt.Errorf("Failed to load custom conf '%s': %v", setting.CustomConf, err)
144-
}
145-
}
166+
func setPort(port string) error {
167+
setting.AppURL = strings.Replace(setting.AppURL, setting.HTTPPort, port, 1)
168+
setting.HTTPPort = port
146169

147-
defaultLocalURL := string(setting.Protocol) + "://"
148-
if setting.HTTPAddr == "0.0.0.0" {
149-
defaultLocalURL += "localhost"
150-
} else {
151-
defaultLocalURL += setting.HTTPAddr
170+
switch setting.Protocol {
171+
case setting.UnixSocket:
172+
case setting.FCGI:
173+
case setting.FCGIUnix:
174+
default:
175+
// Save LOCAL_ROOT_URL if port changed
176+
cfg := ini.Empty()
177+
isFile, err := util.IsFile(setting.CustomConf)
178+
if err != nil {
179+
log.Fatal("Unable to check if %s is a file", err)
180+
}
181+
if isFile {
182+
// Keeps custom settings if there is already something.
183+
if err := cfg.Append(setting.CustomConf); err != nil {
184+
return fmt.Errorf("Failed to load custom conf '%s': %v", setting.CustomConf, err)
152185
}
153-
defaultLocalURL += ":" + setting.HTTPPort + "/"
186+
}
187+
188+
defaultLocalURL := string(setting.Protocol) + "://"
189+
if setting.HTTPAddr == "0.0.0.0" {
190+
defaultLocalURL += "localhost"
191+
} else {
192+
defaultLocalURL += setting.HTTPAddr
193+
}
194+
defaultLocalURL += ":" + setting.HTTPPort + "/"
154195

155-
cfg.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL)
196+
cfg.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL)
156197

157-
if err := cfg.SaveTo(setting.CustomConf); err != nil {
158-
return fmt.Errorf("Error saving generated JWT Secret to custom config: %v", err)
159-
}
198+
if err := cfg.SaveTo(setting.CustomConf); err != nil {
199+
return fmt.Errorf("Error saving generated JWT Secret to custom config: %v", err)
160200
}
161201
}
202+
return nil
203+
}
162204

205+
func listen(m *macaron.Macaron, handleRedirector bool) error {
163206
listenAddr := setting.HTTPAddr
164207
if setting.Protocol != setting.UnixSocket && setting.Protocol != setting.FCGIUnix {
165208
listenAddr = net.JoinHostPort(listenAddr, setting.HTTPPort)
@@ -170,37 +213,40 @@ func runWeb(ctx *cli.Context) error {
170213
log.Info("LFS server enabled")
171214
}
172215

173-
if setting.EnablePprof {
174-
go func() {
175-
log.Info("Starting pprof server on localhost:6060")
176-
log.Info("%v", http.ListenAndServe("localhost:6060", nil))
177-
}()
178-
}
179-
180216
var err error
181217
switch setting.Protocol {
182218
case setting.HTTP:
183-
NoHTTPRedirector()
219+
if handleRedirector {
220+
NoHTTPRedirector()
221+
}
184222
err = runHTTP("tcp", listenAddr, context2.ClearHandler(m))
185223
case setting.HTTPS:
186224
if setting.EnableLetsEncrypt {
187225
err = runLetsEncrypt(listenAddr, setting.Domain, setting.LetsEncryptDirectory, setting.LetsEncryptEmail, context2.ClearHandler(m))
188226
break
189227
}
190-
if setting.RedirectOtherPort {
191-
go runHTTPRedirector()
192-
} else {
193-
NoHTTPRedirector()
228+
if handleRedirector {
229+
if setting.RedirectOtherPort {
230+
go runHTTPRedirector()
231+
} else {
232+
NoHTTPRedirector()
233+
}
194234
}
195235
err = runHTTPS("tcp", listenAddr, setting.CertFile, setting.KeyFile, context2.ClearHandler(m))
196236
case setting.FCGI:
197-
NoHTTPRedirector()
237+
if handleRedirector {
238+
NoHTTPRedirector()
239+
}
198240
err = runFCGI("tcp", listenAddr, context2.ClearHandler(m))
199241
case setting.UnixSocket:
200-
NoHTTPRedirector()
242+
if handleRedirector {
243+
NoHTTPRedirector()
244+
}
201245
err = runHTTP("unix", listenAddr, context2.ClearHandler(m))
202246
case setting.FCGIUnix:
203-
NoHTTPRedirector()
247+
if handleRedirector {
248+
NoHTTPRedirector()
249+
}
204250
err = runFCGI("unix", listenAddr, context2.ClearHandler(m))
205251
default:
206252
log.Fatal("Invalid protocol: %s", setting.Protocol)
@@ -210,8 +256,5 @@ func runWeb(ctx *cli.Context) error {
210256
log.Critical("Failed to start server: %v", err)
211257
}
212258
log.Info("HTTP Listener: %s Closed", listenAddr)
213-
<-graceful.GetManager().Done()
214-
log.Info("PID: %d Gitea Web Finished", os.Getpid())
215-
log.Close()
216-
return nil
259+
return err
217260
}

cmd/web_graceful.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ func NoMainListener() {
3737
graceful.GetManager().InformCleanup()
3838
}
3939

40+
// NoInstallListener tells our cleanup routine that we will not be using a possibly provided listener
41+
// for our install HTTP/HTTPS service
42+
func NoInstallListener() {
43+
graceful.GetManager().InformCleanup()
44+
}
45+
4046
func runFCGI(network, listenAddr string, m http.Handler) error {
4147
// This needs to handle stdin as fcgi point
4248
fcgiServer := graceful.NewServer(network, listenAddr)

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
251251
- `SSH_LISTEN_PORT`: **%(SSH\_PORT)s**: Port for the built-in SSH server.
252252
- `SSH_ROOT_PATH`: **~/.ssh**: Root path of SSH directory.
253253
- `SSH_CREATE_AUTHORIZED_KEYS_FILE`: **true**: Gitea will create a authorized_keys file by default when it is not using the internal ssh server. If you intend to use the AuthorizedKeysCommand functionality then you should turn this off.
254+
- `SSH_AUTHORIZED_KEYS_BACKUP`: **true**: Enable SSH Authorized Key Backup when rewriting all keys, default is true.
254255
- `SSH_TRUSTED_USER_CA_KEYS`: **\<empty\>**: Specifies the public keys of certificate authorities that are trusted to sign user certificates for authentication. Multiple keys should be comma separated. E.g.`ssh-<algorithm> <key>` or `ssh-<algorithm> <key1>, ssh-<algorithm> <key2>`. For more information see `TrustedUserCAKeys` in the sshd config man pages. When empty no file will be created and `SSH_AUTHORIZED_PRINCIPALS_ALLOW` will default to `off`.
255256
- `SSH_TRUSTED_USER_CA_KEYS_FILENAME`: **`RUN_USER`/.ssh/gitea-trusted-user-ca-keys.pem**: Absolute path of the `TrustedUserCaKeys` file gitea will manage. If you're running your own ssh server and you want to use the gitea managed file you'll also need to modify your sshd_config to point to this file. The official docker image will automatically work without further configuration.
256257
- `SSH_AUTHORIZED_PRINCIPALS_ALLOW`: **off** or **username, email**: \[off, username, email, anything\]: Specify the principals values that users are allowed to use as principal. When set to `anything` no checks are done on the principal string. When set to `off` authorized principal are not allowed to be set.
@@ -261,7 +262,6 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
261262
- `SSH_SERVER_MACS`: **[email protected], hmac-sha2-256, hmac-sha1, hmac-sha1-96**: For the built-in SSH server, choose the MACs to support for SSH connections, for system SSH this setting has no effect
262263
- `SSH_KEY_TEST_PATH`: **/tmp**: Directory to create temporary files in when testing public keys using ssh-keygen, default is the system temporary directory.
263264
- `SSH_KEYGEN_PATH`: **ssh-keygen**: Path to ssh-keygen, default is 'ssh-keygen' which means the shell is responsible for finding out which one to call.
264-
- `SSH_BACKUP_AUTHORIZED_KEYS`: **true**: Enable SSH Authorized Key Backup when rewriting all keys, default is true.
265265
- `SSH_EXPOSE_ANONYMOUS`: **false**: Enable exposure of SSH clone URL to anonymous visitors, default is false.
266266
- `MINIMUM_KEY_SIZE_CHECK`: **true**: Indicate whether to check minimum key size with corresponding type.
267267

docs/content/doc/advanced/customizing-gitea.en-us.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,15 @@ A full list of supported emoji's is at [emoji list](https://gitea.com/gitea/gite
295295

296296
As of version 1.6.0 Gitea has built-in themes. The two built-in themes are, the default theme `gitea`, and a dark theme `arc-green`. To change the look of your Gitea install change the value of `DEFAULT_THEME` in the [ui](https://docs.gitea.io/en-us/config-cheat-sheet/#ui-ui) section of `app.ini` to another one of the available options.
297297
As of version 1.8.0 Gitea also has per-user themes. The list of themes a user can choose from can be configured with the `THEMES` value in the [ui](https://docs.gitea.io/en-us/config-cheat-sheet/#ui-ui) section of `app.ini` (defaults to `gitea` and `arc-green`, light and dark respectively)
298+
299+
## Customizing fonts
300+
301+
Fonts can be customized using CSS variables:
302+
303+
```css
304+
:root {
305+
--fonts-proportional: /* custom proportional fonts */ !important;
306+
--fonts-monospace: /* custom monospace fonts */ !important;
307+
--fonts-emoji: /* custom emoji fonts */ !important;
308+
}
309+
```

docs/content/doc/installation/with-docker.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ config:
371371

372372
```
373373
[ssh]
374-
SSH_BACKUP_AUTHORIZED_KEYS=false
374+
SSH_AUTHORIZED_KEYS_BACKUP=false
375375
```
376376

377377
- mount your `.ssh` directory directly into the container i.e. add the

modules/context/auth.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ type ToggleOptions struct {
2626
// Toggle returns toggle options as middleware
2727
func Toggle(options *ToggleOptions) macaron.Handler {
2828
return func(ctx *Context) {
29-
// Cannot view any page before installation.
30-
if !setting.InstallLock {
31-
ctx.Redirect(setting.AppSubURL + "/install")
32-
return
33-
}
34-
3529
isAPIPath := auth.IsAPIPath(ctx.Req.URL.Path)
3630

3731
// Check prohibit login users.

modules/graceful/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const (
3131
//
3232
// If you add an additional place you must increment this number
3333
// and add a function to call manager.InformCleanup if it's not going to be used
34-
const numberOfServersToCreate = 3
34+
const numberOfServersToCreate = 4
3535

3636
// Manager represents the graceful server manager interface
3737
var manager *Manager

modules/graceful/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (srv *Server) Serve(serve ServeFunction) error {
162162
srv.setState(stateTerminate)
163163
GetManager().ServerDone()
164164
// use of closed means that the listeners are closed - i.e. we should be shutting down - return nil
165-
if err != nil && strings.Contains(err.Error(), "use of closed") {
165+
if err == nil || strings.Contains(err.Error(), "use of closed") || strings.Contains(err.Error(), "http: Server closed") {
166166
return nil
167167
}
168168
return err

modules/storage/minio.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type minioObject struct {
3232
func (m *minioObject) Stat() (os.FileInfo, error) {
3333
oi, err := m.Object.Stat()
3434
if err != nil {
35-
return nil, err
35+
return nil, convertMinioErr(err)
3636
}
3737

3838
return &minioFileInfo{oi}, nil

options/locale/locale_de-DE.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,6 @@ issues.reopened_at=`hat diesen Issue <a id="%[1]s" href="#%[1]s">%[2]s</a> wiede
10441044
issues.commit_ref_at=`hat dieses Issue <a id="%[1]s" href="#%[1]s">%[2]s</a> aus einem Commit referenziert`
10451045
issues.ref_issue_from=`<a href="%[3]s">verweist auf dieses Issue %[4]s</a> <a id="%[1]s" href="#%[1]s">%[2]s</a>`
10461046
issues.ref_pull_from=`<a href="%[3]s">verweist auf diesen Pull Request %[4]s</a> <a id="%[1]s" href="#%[1]s">%[2]s</a>`
1047-
issues.ref_closing_from=`<a href="%[3]s">hat auf einen Pull Request %[4]s verwiesen, welcher das Issue schließen wird</a> <a id="%[1]s" href="#%[1]s">%[2]s</a>`
10481047
issues.ref_reopening_from=`<a href="%[3]s">hat auf einen Pull Request %[4]s verwiesen, welcher das Issue</a> <a id="%[1]s" href="#%[1]s">%[2]s</a> erneut öffnen wird`
10491048
issues.ref_closed_from=`<a href="%[3]s">hat dieses Issue %[4]s geschlossen</a> <a id="%[1]s" href="#%[1]s">%[2]s</a>`
10501049
issues.ref_reopened_from=`<a href="%[3]s">hat dieses Issue %[4]s</a> <a id="%[1]s" href="#%[1]s">%[2]s</a> wieder geöffnet`

0 commit comments

Comments
 (0)