Skip to content

Commit c2fa157

Browse files
authored
Remove outdated RunUser logic (#37180)
That logic is from 2014~2015, it unclear why it is necessary or whether it is still needed (whether Windows is still special) The comment "so just use current one if config says default" is not right anymore: "git" isn't the "default" value of RunUser (Comment out app.example.ini #15807). The RunUser's value is from current session's username.
1 parent 8fcbdf0 commit c2fa157

File tree

4 files changed

+4
-21
lines changed

4 files changed

+4
-21
lines changed

custom/conf/app.example.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4242
;;
4343
;; App name that shows in every page title
44-
APP_NAME = ; Gitea: Git with a cup of tea
44+
;APP_NAME = Gitea: Git with a cup of tea
4545
;;
4646
;; RUN_USER will automatically detect the current user - but you can set it here change it if you run locally
47-
RUN_USER = ; git
47+
;RUN_USER =
4848
;;
4949
;; Application run mode, affects performance and debugging: "dev" or "prod", default is "prod"
5050
;; Mode "dev" makes Gitea easier to develop and debug, values other than "dev" are treated as "prod" which is for production use.

modules/setting/setting.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func mustCurrentRunUserMatch(rootCfg ConfigProvider) {
201201
if HasInstallLock(rootCfg) {
202202
currentUser, match := IsRunUserMatchCurrentUser(RunUser)
203203
if !match {
204-
log.Fatal("Expect user '%s' but current user is: %s", RunUser, currentUser)
204+
log.Fatal("Expect user '%s' (RUN_USER in app.ini) but current user is: %s", RunUser, currentUser)
205205
}
206206
}
207207
}

options/locale/locale_en-US.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@
316316
"install.invalid_db_table": "The database table \"%s\" is invalid: %v",
317317
"install.invalid_repo_path": "The repository root path is invalid: %v",
318318
"install.invalid_app_data_path": "The app data path is invalid: %v",
319-
"install.run_user_not_match": "The 'run as' username is not the current username: %s -> %s",
320319
"install.internal_token_failed": "Failed to generate internal token: %v",
321320
"install.secret_key_failed": "Failed to generate secret key: %v",
322321
"install.save_config_failed": "Failed to save configuration: %v",

routers/install/install.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"code.gitea.io/gitea/modules/setting"
2727
"code.gitea.io/gitea/modules/templates"
2828
"code.gitea.io/gitea/modules/timeutil"
29-
"code.gitea.io/gitea/modules/user"
3029
"code.gitea.io/gitea/modules/web"
3130
"code.gitea.io/gitea/modules/web/middleware"
3231
"code.gitea.io/gitea/routers/common"
@@ -87,15 +86,7 @@ func Install(ctx *context.Context) {
8786
form.AppName = setting.AppName
8887
form.RepoRootPath = setting.RepoRootPath
8988
form.LFSRootPath = setting.LFS.Storage.Path
90-
91-
// Note(unknown): it's hard for Windows users change a running user,
92-
// so just use current one if config says default.
93-
if setting.IsWindows && setting.RunUser == "git" {
94-
form.RunUser = user.CurrentUsername()
95-
} else {
96-
form.RunUser = setting.RunUser
97-
}
98-
89+
form.RunUser = setting.RunUser
9990
form.Domain = setting.Domain
10091
form.SSHPort = setting.SSH.Port
10192
form.HTTPPort = setting.HTTPPort
@@ -272,13 +263,6 @@ func SubmitInstall(ctx *context.Context) {
272263
return
273264
}
274265

275-
currentUser, match := setting.IsRunUserMatchCurrentUser(form.RunUser)
276-
if !match {
277-
ctx.Data["Err_RunUser"] = true
278-
ctx.RenderWithErrDeprecated(ctx.Tr("install.run_user_not_match", form.RunUser, currentUser), tplInstall, &form)
279-
return
280-
}
281-
282266
// Check logic loophole between disable self-registration and no admin account.
283267
if form.DisableRegistration && len(form.AdminName) == 0 {
284268
ctx.Data["Err_Services"] = true

0 commit comments

Comments
 (0)