diff options
author | Giteabot <teabot@gitea.io> | 2023-06-24 10:04:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-24 14:04:50 +0000 |
commit | 71d2a6a41a7fea7a71efa125f47567b5cb5ba56a (patch) | |
tree | 97b93375c0e3702ce3f4cbcb84c7c99bdf9d4600 /modules | |
parent | d1f1f1142ed6fd58e521587454a36827c320a5f6 (diff) | |
download | gitea-71d2a6a41a7fea7a71efa125f47567b5cb5ba56a.tar.gz gitea-71d2a6a41a7fea7a71efa125f47567b5cb5ba56a.zip |
Use InitWorkPathAndCfgProvider for environment-to-ini to avoid unnecessary checks (#25480) (#25488)v1.20.0-rc2
Backport #25480 by @wxiaoguang
Fix #25481
The `InitWorkPathAndCommonConfig` calls `LoadCommonSettings` which does
many checks like "current user is root or not".
Some commands like "environment-to-ini" shouldn't do such check, because
it might be run with "root" user at the moment (eg: the docker's setup
script)
ps: in the future, the docker's setup script should be improved to avoid
Gitea's command running with "root"
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/setting/path.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/setting/path.go b/modules/setting/path.go index 91bb2e9bb7..163f1d1590 100644 --- a/modules/setting/path.go +++ b/modules/setting/path.go @@ -89,6 +89,12 @@ func (s *stringWithDefault) Set(v string) { // InitWorkPathAndCommonConfig will set AppWorkPath, CustomPath and CustomConf, init default config provider by CustomConf and load common settings, func InitWorkPathAndCommonConfig(getEnvFn func(name string) string, args ArgWorkPathAndCustomConf) { + InitWorkPathAndCfgProvider(getEnvFn, args) + LoadCommonSettings() +} + +// InitWorkPathAndCfgProvider will set AppWorkPath, CustomPath and CustomConf, init default config provider by CustomConf +func InitWorkPathAndCfgProvider(getEnvFn func(name string) string, args ArgWorkPathAndCustomConf) { tryAbsPath := func(paths ...string) string { s := paths[len(paths)-1] for i := len(paths) - 2; i >= 0; i-- { @@ -186,6 +192,4 @@ func InitWorkPathAndCommonConfig(getEnvFn func(name string) string, args ArgWork AppWorkPath = tmpWorkPath.Value CustomPath = tmpCustomPath.Value CustomConf = tmpCustomConf.Value - - LoadCommonSettings() } |