Skip to content

Commit ef57ba5

Browse files
wolfogreGiteaBotwxiaoguang
committed
Support GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT env (go-gitea#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 <[email protected]> Co-authored-by: wxiaoguang <[email protected]>
1 parent e03cf66 commit ef57ba5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

modules/setting/setting.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"code.gitea.io/gitea/modules/log"
1515
"code.gitea.io/gitea/modules/user"
16+
"code.gitea.io/gitea/modules/util"
1617
)
1718

1819
// settings
@@ -158,9 +159,11 @@ func loadCommonSettingsFrom(cfg ConfigProvider) error {
158159
func loadRunModeFrom(rootCfg ConfigProvider) {
159160
rootSec := rootCfg.Section("")
160161
RunUser = rootSec.Key("RUN_USER").MustString(user.CurrentUsername())
162+
161163
// The following is a purposefully undocumented option. Please do not run Gitea as root. It will only cause future headaches.
162164
// Please don't use root as a bandaid to "fix" something that is broken, instead the broken thing should instead be fixed properly.
163165
unsafeAllowRunAsRoot := ConfigSectionKeyBool(rootSec, "I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")
166+
unsafeAllowRunAsRoot = unsafeAllowRunAsRoot || util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value()
164167
RunMode = os.Getenv("GITEA_RUN_MODE")
165168
if RunMode == "" {
166169
RunMode = rootSec.Key("RUN_MODE").MustString("prod")

0 commit comments

Comments
 (0)