After upgrade, startup fails with "/var/lib/gitea/repos/user/repo.git/hooks/proc-receive.d/gitea: permission denied" (path does not exist) #8617

Closed
opened 2025-11-02 08:12:32 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @gavinbeatty on GitHub (Feb 25, 2022).

Gitea Version

1.16.2

Git Version

2.35.1

Operating System

Linux 5.15.24-3-rpi-ARCH #1 SMP Wed Feb 23 22:17:12 UTC 2022 armv7l GNU/Linux

How are you running Gitea?

Self-created gitea package, but only modifying two variables from https://github.com/archlinux/svntogit-community/blob/packages/gitea/trunk/PKGBUILD: _tag=8ebf0e68ec2899584cef9cf0674a2c4650c00823 and pkgver=1.16.2

Database

SQLite

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

https://gist.github.com/gavinbeatty/8776e61c7e5c067a6a9259d8ab6389fc

Description

The directory /var/lib/gitea/repos/user/repo.git/hooks/proc-receive.d exists, but it is empty. Running the following gives "Permission denied", so I presume go is making an errant unlink syscall on the non-existent path.

sudo -u gitea -g gitea rm /var/lib/gitea/repos/user/repo.git/hooks/proc-receive.d/gitea
rm: cannot remove '/var/lib/gitea/repos/user/repo.git/hooks/proc-receive.d/gitea': Permission denied
sudo -u gitea -g gitea ls -l /var/lib/gitea/repos/user/repo.git/hooks/proc-receive.d
total 0

Screenshots

No response

Originally created by @gavinbeatty on GitHub (Feb 25, 2022). ### Gitea Version 1.16.2 ### Git Version 2.35.1 ### Operating System Linux 5.15.24-3-rpi-ARCH #1 SMP Wed Feb 23 22:17:12 UTC 2022 armv7l GNU/Linux ### How are you running Gitea? Self-created gitea package, but only modifying two variables from https://github.com/archlinux/svntogit-community/blob/packages/gitea/trunk/PKGBUILD: _tag=8ebf0e68ec2899584cef9cf0674a2c4650c00823 and pkgver=1.16.2 ### Database SQLite ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist https://gist.github.com/gavinbeatty/8776e61c7e5c067a6a9259d8ab6389fc ### Description The directory /var/lib/gitea/repos/user/repo.git/hooks/proc-receive.d exists, but it is empty. Running the following gives "Permission denied", so I presume go is making an errant unlink syscall on the non-existent path. ```sh sudo -u gitea -g gitea rm /var/lib/gitea/repos/user/repo.git/hooks/proc-receive.d/gitea rm: cannot remove '/var/lib/gitea/repos/user/repo.git/hooks/proc-receive.d/gitea': Permission denied sudo -u gitea -g gitea ls -l /var/lib/gitea/repos/user/repo.git/hooks/proc-receive.d total 0 ``` ### Screenshots _No response_
Author
Owner

@gavinbeatty commented on GitHub (Feb 25, 2022):

This causes startup to fail (in the migration case, and every subsequent startup).

@gavinbeatty commented on GitHub (Feb 25, 2022): This causes startup to fail (in the migration case, and every subsequent startup).
Author
Owner

@gavinbeatty commented on GitHub (Feb 25, 2022):

Note that because the manual sudo -u gitea -g gitea rm fails, this is not connected to anything like SystemCallErrorNumber=EPERM in gitea.service (sudo does not use the service file), so it is not solved by any remedy in #9792.

Curiously, regular sudo rm as "root" fails with "No such file or directory", which looks to be what 8ebf0e68ec/modules/repository/hooks.go (L140) expects.

@gavinbeatty commented on GitHub (Feb 25, 2022): Note that because the manual `sudo -u gitea -g gitea rm` fails, this is not connected to anything like `SystemCallErrorNumber=EPERM` in gitea.service (sudo does not use the service file), so it is not solved by any remedy in #9792. Curiously, regular `sudo rm` as "root" fails with "No such file or directory", which looks to be what https://github.com/go-gitea/gitea/blob/8ebf0e68ec2899584cef9cf0674a2c4650c00823/modules/repository/hooks.go#L140 expects.
Author
Owner

@gavinbeatty commented on GitHub (Feb 25, 2022):

I should also note that I am running the linux-amd64 binary release of 1.16.1 (not 1.16.2) on another host, having upgraded from a 1.15 version. with no issue, Linux 5.10.0-11-amd64 #1 SMP Debian 5.10.92-1 (2022-01-18) x86_64 GNU/Linux

@gavinbeatty commented on GitHub (Feb 25, 2022): I should also note that I am running the linux-amd64 binary release of 1.16.1 (not 1.16.2) on another host, having upgraded from a 1.15 version. with no issue, Linux 5.10.0-11-amd64 #1 SMP Debian 5.10.92-1 (2022-01-18) x86_64 GNU/Linux
Author
Owner

@gavinbeatty commented on GitHub (Feb 26, 2022):

My apologies. This is just a permissions issue. Some faulty "hardening" using UMask in the systemd unit.

@gavinbeatty commented on GitHub (Feb 26, 2022): My apologies. This is just a permissions issue. Some faulty "hardening" using UMask in the systemd unit.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#8617