mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-23 23:03:34 +01:00
#3158 skip RUN_USER check on Windows
This commit is contained in:
parent
b0b88d9bc5
commit
edd786446c
5 changed files with 24 additions and 10 deletions
|
@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
|
||||||
|
|
||||||
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
||||||
|
|
||||||
##### Current tip version: 0.9.69 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
|
##### Current tip version: 0.9.70 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
|
||||||
|
|
||||||
| Web | UI | Preview |
|
| Web | UI | Preview |
|
||||||
|:-------------:|:-------:|:-------:|
|
|:-------------:|:-------:|:-------:|
|
||||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.9.69.0808"
|
const APP_VER = "0.9.70.0808"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -285,6 +285,19 @@ func forcePathSeparator(path string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsRunUserMatchCurrentUser returns false if configured run user does not match
|
||||||
|
// actual user that runs the app. The first return value is the actual user name.
|
||||||
|
// This check is ignored under Windows since SSH remote login is not the main
|
||||||
|
// method to login on Windows.
|
||||||
|
func IsRunUserMatchCurrentUser(runUser string) (string, bool) {
|
||||||
|
if IsWindows {
|
||||||
|
return "", true
|
||||||
|
}
|
||||||
|
|
||||||
|
currentUser := user.CurrentUsername()
|
||||||
|
return currentUser, runUser == currentUser
|
||||||
|
}
|
||||||
|
|
||||||
// NewContext initializes configuration context.
|
// NewContext initializes configuration context.
|
||||||
// NOTE: do not print any log except error.
|
// NOTE: do not print any log except error.
|
||||||
func NewContext() {
|
func NewContext() {
|
||||||
|
@ -431,10 +444,12 @@ func NewContext() {
|
||||||
}[Cfg.Section("time").Key("FORMAT").MustString("RFC1123")]
|
}[Cfg.Section("time").Key("FORMAT").MustString("RFC1123")]
|
||||||
|
|
||||||
RunUser = Cfg.Section("").Key("RUN_USER").String()
|
RunUser = Cfg.Section("").Key("RUN_USER").String()
|
||||||
curUser := user.CurrentUsername()
|
|
||||||
// Does not check run user when the install lock is off.
|
// Does not check run user when the install lock is off.
|
||||||
if InstallLock && RunUser != curUser {
|
if InstallLock {
|
||||||
log.Fatal(4, "Expect user(%s) but current user is: %s", RunUser, curUser)
|
currentUser, match := IsRunUserMatchCurrentUser(RunUser)
|
||||||
|
if !match {
|
||||||
|
log.Fatal(4, "Expect user '%s' but current user is: %s", RunUser, currentUser)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine and create root git repository path.
|
// Determine and create root git repository path.
|
||||||
|
|
|
@ -252,11 +252,10 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check run user.
|
currentUser, match := setting.IsRunUserMatchCurrentUser(form.RunUser)
|
||||||
curUser := user.CurrentUsername()
|
if !match {
|
||||||
if form.RunUser != curUser {
|
|
||||||
ctx.Data["Err_RunUser"] = true
|
ctx.Data["Err_RunUser"] = true
|
||||||
ctx.RenderWithErr(ctx.Tr("install.run_user_not_match", form.RunUser, curUser), INSTALL, &form)
|
ctx.RenderWithErr(ctx.Tr("install.run_user_not_match", form.RunUser, currentUser), INSTALL, &form)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.9.69.0808
|
0.9.70.0808
|
Loading…
Reference in a new issue