diff options
author | zeripath <art27@cantab.net> | 2019-12-27 21:15:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-27 21:15:04 +0000 |
commit | 4acca9d2e8618a5283495fcd3b313fd53c953f18 (patch) | |
tree | 3c0cfba28db36ae362e257b3fafe43773e9f30d2 /cmd | |
parent | f2d03cda96eb5febbf9801f6b6cf5daa37220bc9 (diff) | |
download | gitea-4acca9d2e8618a5283495fcd3b313fd53c953f18.tar.gz gitea-4acca9d2e8618a5283495fcd3b313fd53c953f18.zip |
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!
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/hook.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/cmd/hook.go b/cmd/hook.go index ebd230999a..aabd9637c2 100644 --- a/cmd/hook.go +++ b/cmd/hook.go @@ -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") |