mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-22 01:44:24 +01:00
Support GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT env (#29788)
It is convenient to skip by setting environment, since it's OK to use root user in job containers. It's not a bug, but I want to backport it to v1.21 since it doesn't break anything. --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> (cherry picked from commit 487ac9bf6c239ce897f1a2f6c4321d6f1769a22f)
This commit is contained in:
parent
4069429114
commit
9d08d00dbf
|
@ -13,6 +13,7 @@ import (
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/user"
|
"code.gitea.io/gitea/modules/user"
|
||||||
|
"code.gitea.io/gitea/modules/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ForgejoVersion = "1.0.0"
|
var ForgejoVersion = "1.0.0"
|
||||||
|
@ -161,9 +162,11 @@ func loadCommonSettingsFrom(cfg ConfigProvider) error {
|
||||||
func loadRunModeFrom(rootCfg ConfigProvider) {
|
func loadRunModeFrom(rootCfg ConfigProvider) {
|
||||||
rootSec := rootCfg.Section("")
|
rootSec := rootCfg.Section("")
|
||||||
RunUser = rootSec.Key("RUN_USER").MustString(user.CurrentUsername())
|
RunUser = rootSec.Key("RUN_USER").MustString(user.CurrentUsername())
|
||||||
|
|
||||||
// The following is a purposefully undocumented option. Please do not run Gitea as root. It will only cause future headaches.
|
// The following is a purposefully undocumented option. Please do not run Gitea as root. It will only cause future headaches.
|
||||||
// Please don't use root as a bandaid to "fix" something that is broken, instead the broken thing should instead be fixed properly.
|
// Please don't use root as a bandaid to "fix" something that is broken, instead the broken thing should instead be fixed properly.
|
||||||
unsafeAllowRunAsRoot := ConfigSectionKeyBool(rootSec, "I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")
|
unsafeAllowRunAsRoot := ConfigSectionKeyBool(rootSec, "I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")
|
||||||
|
unsafeAllowRunAsRoot = unsafeAllowRunAsRoot || util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value()
|
||||||
RunMode = os.Getenv("GITEA_RUN_MODE")
|
RunMode = os.Getenv("GITEA_RUN_MODE")
|
||||||
if RunMode == "" {
|
if RunMode == "" {
|
||||||
RunMode = rootSec.Key("RUN_MODE").MustString("prod")
|
RunMode = rootSec.Key("RUN_MODE").MustString("prod")
|
||||||
|
|
Loading…
Reference in a new issue