diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-07-10 06:43:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-09 22:43:37 +0000 |
commit | fa0b5b14c2faa6a5f76bb2e7bc9241a5e4354189 (patch) | |
tree | 885a32e803e934883ca047116441f56ac9435b5b /modules/setting/setting.go | |
parent | 61e0d1a767e1a1a509de9de4aff42bdb79cc6443 (diff) | |
download | gitea-fa0b5b14c2faa6a5f76bb2e7bc9241a5e4354189.tar.gz gitea-fa0b5b14c2faa6a5f76bb2e7bc9241a5e4354189.zip |
Make "install page" respect environment config (#25648)
Replace #25580
Fix #19453
The problem was: when users set "GITEA__XXX__YYY" , the "install page"
doesn't respect it.
So, to make the result consistent and avoid surprising end users, now
the "install page" also writes the environment variables to the config
file.
And, to make things clear, there are enough messages on the UI to tell
users what will happen.
There are some necessary/related changes to `environment-to-ini.go`:
* The "--clear" flag is removed and it was incorrectly written there.
The "clear" operation should be done if INSTALL_LOCK=true
* The "--prefix" flag is removed because it's never used, never
documented and it only causes inconsistent behavior.

Diffstat (limited to 'modules/setting/setting.go')
-rw-r--r-- | modules/setting/setting.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 0d69847dbe..d444d9a017 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -183,10 +183,14 @@ func loadRunModeFrom(rootCfg ConfigProvider) { } } +// HasInstallLock checks the install-lock in ConfigProvider directly, because sometimes the config file is not loaded into setting variables yet. +func HasInstallLock(rootCfg ConfigProvider) bool { + return rootCfg.Section("security").Key("INSTALL_LOCK").MustBool(false) +} + func mustCurrentRunUserMatch(rootCfg ConfigProvider) { // Does not check run user when the "InstallLock" is off. - installLock := rootCfg.Section("security").Key("INSTALL_LOCK").MustBool(false) - if installLock { + if HasInstallLock(rootCfg) { currentUser, match := IsRunUserMatchCurrentUser(RunUser) if !match { log.Fatal("Expect user '%s' but current user is: %s", RunUser, currentUser) |