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

Hooks fail silently if wrong permission #20771

Closed
TheLovinator1 opened this issue Aug 12, 2022 · 8 comments
Closed

Hooks fail silently if wrong permission #20771

TheLovinator1 opened this issue Aug 12, 2022 · 8 comments
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail

Comments

@TheLovinator1
Copy link

TheLovinator1 commented Aug 12, 2022

Description

Hi,

Context:
I moved my Gitea files from Linux -> Windows -> Linux and lost my permissions.

Problem:
If the files in /git/repositories/username/gitrepo.git/hooks have the wrong file permissions (644 instead of 755) the hooks will fail without any errors. This breaks webhooks and no changes will be seen on the frontpage.

What I expected:
Gitea should change the permissions to the correct one or you should at least get a error message in the logs or failed delivery under Recent Deliveries.

Gitea Version

1.18.0+dev-265-gc81b26b0e

Git Version

2.36.2

How are you running Gitea?

Running docker with the gitea/gitea:dev image

Database

PostgreSQL

@lunny
Copy link
Member

lunny commented Aug 12, 2022

You could run gitea doctor to check and fix them, but it should not be automatically fixed.

@lunny lunny added issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail and removed type/bug labels Aug 12, 2022
@TheLovinator1
Copy link
Author

TheLovinator1 commented Aug 12, 2022

How do I run gitea doctor on gitea/gitea:dev?

gitea/gitea:
sudo docker exec -ti gitea-stable su git bash -c "cd /data/gitea/ && gitea doctor --fix"

[1] Check paths and basic configuration

  • [I] Configuration File Path: "/data/gitea/conf/app.ini"
  • [I] Repository Root Path: "/data/git/repositories"
  • [I] Data Root Path: "/data/gitea"
  • [I] Custom File Root Path: "/data/gitea"
  • [I] Work directory: "/app/gitea"
  • [I] Log Root Path: "/data/gitea/log"
    OK
    [2] Check Database Version
    OK
    [3] Check if user with wrong type exist
    OK
    [4] Check if OpenSSH authorized_keys file is up-to-date
    OK

gitea/gitea:dev:
sudo docker exec -ti gitea-dev su git bash -c "cd /data/gitea/ && gitea doctor --fix"

2022/08/12 21:10:02 main.go:118:main() [F] Failed to run app with [/usr/local/bin/gitea doctor --fix]: unable to init Git's HomeDir, incorrect initialization of the setting and git modules


Also I get this when running gitea doctor --fix in the root directory on the stable version of Gitea, so I have no idea if I am even doing it correct. What directory should I be in?

sudo docker exec -ti gitea-stable su git bash -c "gitea doctor --fix"

panic: Failed to create sublogger (doctor): open doctor.log: permission denied

goroutine 1 [running]:
code.gitea.io/gitea/modules/log.NewLogger(0x2c2829c?, {0x29efa18?, 0xc001b3e728?}, {0x29d1d66?, 0x1?}, {0xc00160bd10?, 0x45c969?})
/go/src/code.gitea.io/gitea/modules/log/log.go:49 +0x105
code.gitea.io/gitea/cmd.runDoctor(0xc00027f600)
/go/src/code.gitea.io/gitea/cmd/doctor.go:150 +0x27e
github.com/urfave/cli.HandleAction({0x257ba80?, 0x37f7a60?}, 0xc002686a80?)
/go/pkg/mod/github.com/urfave/[email protected]/app.go:524 +0xa8
github.com/urfave/cli.(*App).RunAsSubcommand(0xc002686a80, 0xc00027f4a0)
/go/pkg/mod/github.com/urfave/[email protected]/app.go:410 +0x831
github.com/urfave/cli.Command.startApp({{0x29efa18, 0x6}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x2bdc6ca, 0x24}, {0x0, ...}, ...}, ...)
/go/pkg/mod/github.com/urfave/[email protected]/command.go:378 +0x6e7
github.com/urfave/cli.Command.Run({{0x29efa18, 0x6}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x2bdc6ca, 0x24}, {0x0, ...}, ...}, ...)
/go/pkg/mod/github.com/urfave/[email protected]/command.go:102 +0x808
github.com/urfave/cli.(*App).Run(0xc0026868c0, {0xc00011a150, 0x3, 0x3})
/go/pkg/mod/github.com/urfave/[email protected]/app.go:277 +0x8a7
main.main()
/go/src/code.gitea.io/gitea/main.go:116 +0xcf9

@ghost
Copy link

ghost commented Aug 13, 2022

panic: Failed to create sublogger (doctor): open doctor.log: permission denied

have a try with doctor:

docker exec -it --user git --workdir=/tmp gitea bash
gitea doctor --run hooks --fix

@TheLovinator1
Copy link
Author

docker exec -it --user git --workdir=/tmp gitea bash
gitea doctor --run hooks --fix

2022/08/13 13:35:40 main.go:118:main() [F] Failed to run app with [/usr/local/bin/gitea doctor --run hooks --fix]: unable to init Git's HomeDir, incorrect initialization of the setting and git modules

This is what I get with a clean new version of gitea/gitea:dev with nothing on it, so it has broke since the last stable version.

@ghost
Copy link

ghost commented Aug 13, 2022

2022/08/13 13:35:40 main.go:118:main() [F] Failed to run app with [/usr/local/bin/gitea doctor --run hooks --fix]: unable to init Git's HomeDir, incorrect initialization of the setting and git modules

according to #20114 #20293 @wxiaoguang may know this issue

@wxiaoguang
Copy link
Contributor

Actually, it's related to this one

The git.InitFull expects that the the settings.LoadConfXxx has been called before. But in doctor sub-command, it hasn't.

I will take a look at about the config system + git module dependency.

@wxiaoguang
Copy link
Contributor

The backport for 1.17: #20783
The fix for 1.18: #20782

@TheLovinator1
Copy link
Author

TheLovinator1 commented Aug 13, 2022

Thanks, tried gitea doctor --run hooks --fix on 1.18.0+dev-272-g11dc6df5b and the hooks are working again :)

@lunny lunny closed this as completed Aug 14, 2022
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail
Projects
None yet
Development

No branches or pull requests

3 participants