1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Properly enforce gitea environment for pushes (#9501)

#8982 attempted to enforce the gitea environment for pushes - unfortunately it tested the settings before they were actually read in - and therefore does not do that!
This commit is contained in:
zeripath
2019-12-27 21:15:04 +00:00
committed by GitHub
parent f2d03cda96
commit 4acca9d2e8
6 changed files with 36 additions and 8 deletions

View File

@@ -59,6 +59,12 @@ var (
)
func runHookPreReceive(c *cli.Context) error {
if os.Getenv(models.EnvIsInternal) == "true" {
return nil
}
setup("hooks/pre-receive.log", false)
if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
if setting.OnlyAllowPushIfGiteaEnvironmentSet {
fail(`Rejecting changes as Gitea environment not set.
@@ -69,8 +75,6 @@ Gitea or set your environment appropriately.`, "")
}
}
setup("hooks/pre-receive.log", false)
// the environment setted on serv command
isWiki := (os.Getenv(models.EnvRepoIsWiki) == "true")
username := os.Getenv(models.EnvRepoUsername)
@@ -186,6 +190,12 @@ func runHookUpdate(c *cli.Context) error {
}
func runHookPostReceive(c *cli.Context) error {
if os.Getenv(models.EnvIsInternal) == "true" {
return nil
}
setup("hooks/post-receive.log", false)
if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
if setting.OnlyAllowPushIfGiteaEnvironmentSet {
fail(`Rejecting changes as Gitea environment not set.
@@ -196,8 +206,6 @@ Gitea or set your environment appropriately.`, "")
}
}
setup("hooks/post-receive.log", false)
// the environment setted on serv command
repoUser := os.Getenv(models.EnvRepoUsername)
isWiki := (os.Getenv(models.EnvRepoIsWiki) == "true")