Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT env (#29788) #29791

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/user"
"code.gitea.io/gitea/modules/util"
)

// settings
Expand Down Expand Up @@ -158,9 +159,11 @@
func loadRunModeFrom(rootCfg ConfigProvider) {
rootSec := rootCfg.Section("")
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.
// 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 = unsafeAllowRunAsRoot || util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value()

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / test-mssql

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / test-pgsql

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / test-mysql8

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / test-mysql5

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / test-unit

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / test-e2e

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / test-sqlite

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / backend

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / checks-backend

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / lint-go-windows

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)) (typecheck)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / lint-go-windows

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)) (typecheck)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / lint-go-windows

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)) (typecheck)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / lint-go-windows

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)) (typecheck)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / lint-go-windows

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)) (typecheck)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / lint-backend

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)) (typecheck)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / lint-backend

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)) (typecheck)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / lint-backend

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)) (typecheck)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / lint-backend

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)) (typecheck)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / lint-backend

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)) (typecheck)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / lint-go-gogit

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)) (typecheck)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / lint-go-gogit

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)) (typecheck)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / lint-go-gogit

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)) (typecheck)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / lint-go-gogit

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)) (typecheck)

Check failure on line 166 in modules/setting/setting.go

View workflow job for this annotation

GitHub Actions / lint-go-gogit

util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value undefined (type "code.gitea.io/gitea/modules/util".OptionalBool has no field or method Value)) (typecheck)
RunMode = os.Getenv("GITEA_RUN_MODE")
if RunMode == "" {
RunMode = rootSec.Key("RUN_MODE").MustString("prod")
Expand Down
Loading