mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-09 04:25:18 -05:00
Permission denied error when starting Gitea after updating to 1.17.0 #9297
Closed
opened 2025-11-02 08:34:21 -06:00 by GiteaMirror
·
40 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v1.16.0
v1.15.11
v1.17.0-dev
v1.16.0-rc1
v1.15.10
v1.15.9
v1.15.8
v1.15.7
v1.15.6
v1.15.5
v1.15.4
v1.15.3
v1.15.2
v1.15.1
v1.14.7
v1.15.0
v1.15.0-rc3
v1.14.6
v1.15.0-rc2
v1.14.5
v1.16.0-dev
v1.15.0-rc1
v1.14.4
v1.14.3
v1.14.2
v1.14.1
v1.14.0
v1.13.7
v1.14.0-rc2
v1.13.6
v1.13.5
v1.14.0-rc1
v1.15.0-dev
v1.13.4
v1.13.3
v1.13.2
v1.13.1
v1.13.0
v1.12.6
v1.13.0-rc2
v1.14.0-dev
v1.13.0-rc1
v1.12.5
v1.12.4
v1.12.3
v1.12.2
v1.12.1
v1.11.8
v1.12.0
v1.11.7
v1.12.0-rc2
v1.11.6
v1.12.0-rc1
v1.13.0-dev
v1.11.5
v1.11.4
v1.11.3
v1.10.6
v1.12.0-dev
v1.11.2
v1.10.5
v1.11.1
v1.10.4
v1.11.0
v1.11.0-rc2
v1.10.3
v1.11.0-rc1
v1.10.2
v1.10.1
v1.10.0
v1.9.6
v1.9.5
v1.10.0-rc2
v1.11.0-dev
v1.10.0-rc1
v1.9.4
v1.9.3
v1.9.2
v1.9.1
v1.9.0
v1.9.0-rc2
v1.10.0-dev
v1.9.0-rc1
v1.8.3
v1.8.2
v1.8.1
v1.8.0
v1.8.0-rc3
v1.7.6
v1.8.0-rc2
v1.7.5
v1.8.0-rc1
v1.9.0-dev
v1.7.4
v1.7.3
v1.7.2
v1.7.1
v1.7.0
v1.7.0-rc3
v1.6.4
v1.7.0-rc2
v1.6.3
v1.7.0-rc1
v1.7.0-dev
v1.6.2
v1.6.1
v1.6.0
v1.6.0-rc2
v1.5.3
v1.6.0-rc1
v1.6.0-dev
v1.5.2
v1.5.1
v1.5.0
v1.5.0-rc2
v1.5.0-rc1
v1.5.0-dev
v1.4.3
v1.4.2
v1.4.1
v1.4.0
v1.4.0-rc3
v1.4.0-rc2
v1.3.3
v1.4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#9297
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mpeter50 on GitHub (Jul 31, 2022).
Description
I have updated to Gitea 1.17.0, but when starting it I receive an error in the console, and then it exits. The message is available in the first file of my log gist.
In the docker compose file I have 2 volumes defined for use directly by Gitea:
/mnt/gitea/data/-/var/lib/gitea/mnt/gitea/custom-/etc/giteaGitea should run under user 1000, as set up in the docker compose file:
According to the console log, Gitea tries to create the
/var/lib/gitea/custom/homedirectory, which is mapped to/mnt/gitea/data/custom/homeon the host system.After inspecting this latter path, I see that no one is granted write permissions on the
customdirectory in it:However, if I grant write permission to the owner with
sudo chmod u+w custom, Gitea will still produce the same error on startup, then exit, and when exited, the write permission on the directory have disappeared.I suspect that Gitea is unable to create the new
homedirectory because it removes the write permission from it's parent directory, but I also suspect that I might be doing something wrong, as no one else has reported this bug yet.If I try to fix this problem by hand, by manually creating the directory and setting ownership, as seen here:
then starting up Gitea can continue a little, but will exit again because it wants yet another directory besides the new
homeone. The output from this run is in the second file in my log gist.Gitea Version
v1.17.0
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
https://gist.github.com/mpeter50/c7ba7eb7fc5e74fd708736736800a4e6
Screenshots
No response
Git Version
2.36.2
Operating System
Raspbian
How are you running Gitea?
I'm running Gitea in Docker, for which I have built the container image myself, using the Docker.rootless DOckerfile in the repo.
Database
MySQL
@mpeter50 commented on GitHub (Jul 31, 2022):
For the time being, I have reverted to 1.16.5, and it seems to run as expected.
@zeripath commented on GitHub (Jul 31, 2022):
Set
[git].HOME_PATHto an appropriate place for your configuration in app.ini.See the breaking changes notices in our blog post: https://blog.gitea.io/2022/07/gitea-1.17.0-is-released/#-internal-gitconfig-19732httpsgithubcomgo-giteagiteapull19732
Copied below:
Internal Gitconfig (#19732)
Previously, Gitea used the users gitconfig (
$HOME/.gitconfig) in addition to the system gitconfig (/etc/gitconfig).Now, Gitea uses the system gitconfig (
/etc/gitconfig) combined with an internal gitconfig located in{[git].HOME_PATH}/.gitconfig. If you customized your user gitconfig for Gitea, you should add these customizations to one of the available gitconfigs. Additional git-relevant files that are normally in your user home directory, like$HOME/.gnupg, should be moved/ copied to{[git].HOME_PATH}/as well.@mpeter50 commented on GitHub (Jul 31, 2022):
Thank you for the information.
I've read the mentioned breaking change notices, and I haven't modified the gitconfig of the user that runs Gitea.
On the other hand, maybe I misunderstand something, but why should I override the git home path?
The current path is fine to me, and even more, I prefer it to be in the original location. The problem is that Gitea is unable to create this new directory, because it does not have permission to do so. I think this might be caused by Gitea trying to fix the permissions of its own directory, but does it wrongly, and it gets in its own way.
@zeripath commented on GitHub (Jul 31, 2022):
The error you're receiving is stating it can't create what is the new default
[git].HOME_PATHso I suggest you override this.@mpeter50 commented on GitHub (Jul 31, 2022):
I understand, but is that expected behavior? Is this specific to the Docker environment? I'm asking because you have defined that path as the default for a reason.
As far as I'm aware I did not do anything to harden the filesystem permissions of Gitea directories, but Gitea itself does that, and in doing so it breaks itself. If this is the case, I think this is a bug.
@Draic commented on GitHub (Aug 5, 2022):
I changed nothing to any ssh configs but the 1.17 update still breaks my SSH.
@techknowlogick commented on GitHub (Aug 6, 2022):
What is the output of
docker info?@mpeter50 commented on GitHub (Aug 7, 2022):
@zeripath commented on GitHub (Aug 7, 2022):
The
[git]HOME_PATHis a new setting from 1.17.It defaults to
APP_DATA_PATH/home. Where[server]APP_DATA_PATHis/data/giteain the docker and thus/data/gitea/homeSimply create the directory
/data/gitea/homeon the docker and give Gitea permission to write to that directory.@mpeter50 commented on GitHub (Aug 8, 2022):
In my configuration file
[server]APP_DATA_PATHhas the value/var/lib/gitea/custom.I don't remember customizing this value, and according to the compose snippet in the Docker Rootless installation document, most of Gitea data is stored in the parent of this directory by default, so probably this was the default for Docker, at least when I started using Gitea.
I also don't have a
/datadirectory in the container:I haven't customized the value of
[git]HOME_PATH(I don't have agitsection), so this means it should point toAPP_DATA_PATH/home, which is/var/lib/gitea/custom/homein my case.According to the second paragraph in this document. Gitea should try to create the directories it needs, including this one. That is fine because it actually tries to create the directory at
/var/lib/gitea/custom/home, but it fails, because it does not have write permissions on the directory/var/lib/gitea/custom:As you may see, the permissions for the directory is only reading and execution for the
gituser.I haven't modified the permissions, except trying to give the owner of the
/var/lib/gitea/customdirectory write permissions to it, but that was reverted as soon as Gitea started, and it still wasn't able to create the directories that it wanted.I don't have a
/datadirectory, but if I try to create/var/lib/gitea/custom/home:packagesdirectory, and who knows how much more, because Gitea won't be able to create that either@swang-harbin commented on GitHub (Aug 15, 2022):
I installed gitea 1.70 using
sudo snap install giteaon Ubuntu 22.04 LTS, it doesn't automatically create/etc/gitea/app.ini.I create a user called gitea and set its home directory to
/var/lib/gitea, and executesudo mkdir /var/lib/gitea && sudo chown gitee: /var/lib/giteato modify permission. Thegiteauser has all access rights to/var/lib/gitea, as I understand it should not have this error.The
/etc/systemd/system/gitea.serviceis:When I set the
Repository Root Pathto/var/lib/gitea/common/data/gitea-repositoriesandRun As Usernametogiteaon the initial configuration page, it cannot be installed successfully, and it promptsThe repository root path is invalid: mkdir / var/lib/gitea: read-only file system.I don't know what
[git].HOME_PATHis or where it is, because it doesn't have a default configuration file nor is it detailed in the installation process.I think if
[git].HOME_PATHis mandatory, then it should have a default configuration, or specify it before startup as an environment variable. This configuration confuses people.@chris-fj commented on GitHub (Aug 16, 2022):
I am receiving the same error. I have the following mount:
and I have set the following env definitions
and the file
.gitconfighas the following permissionshowever, when starting up the container, I receive this error:
I understand that the user whose UID/GID is defined in the environment is the one performing the operations and, as stated in the
lscommand, said user can read/write the.gitconfigfile. Am I missing something here?@Draic commented on GitHub (Aug 17, 2022):
I made a fresh install on 1.17, which worked for a while. But now it is having the exact same problem as before, with permission errors when it tries to read the SSH key despite its permissions being correct as we established while troubleshooting the issue on Discord. I think 1.17 is flawed
@mpeter50 commented on GitHub (Aug 17, 2022):
@swang-harbin I don't know how to install Gitea that way, but some things I wanted to let you know:
This looks like a path specification problem. I'm not sure where did you set "Repository Root Path", but looking at the error message it looks the first
/has been separated somehow from the rest of the path. Also, I think paths (and other strings) contain characters that need to be escaped if used in systemd unit files; in turn maybe your "Repository Root Path" is ok, and you need to fix the paths in theEnvironmentline and other lines of your unit file that you inserted in your comment. Please check the systemd unit file specification for that.There is the
gitea.inifile (somewhere) that Gitea uses. It is mostly a traditional ini file.The mentioned "path" refers to a
HOME_PATHsetting under the[git]section. If you want to customize it, it should look like this in the said file:Other settings and other sections can be before and after this excerpt, and this section can also contain other settings, but I think you should only define the
[git]section once, so it shouldn't appear more than once.BUT, you don't have to do anything with this setting, or the
[git]section, if you are fine with the default configuration, as by default this setting has the value of <TODO: find it's value, insert here>.@c4tich
I think that is a different error, but it might have some similarities.
Does the git user have the UID of 116, or is it in the group of GID 123?
@mpeter50 commented on GitHub (Aug 17, 2022):
@techknowlogick @zeripath I feel my issue is ignored.
To recap what has happened so far:
I have introduced my problem: Gitea is changing filesystem permissions so that it gets in its own way, and in turn it cannot create the new directories used for the new features of 1.17.
You recommended to change a setting permanently (store a few directories elsewhere), to work around the issue.
I didn't accept that, because it does not solve the actual problem, but creates more on the topic of maintenance.
The reason I didn't accept the workaround to set a different directory for the git home directory, is that my Gitea instance uses the default storage path configurations, and yet it mismanages the directory where it stores all its data.
Gitea has total authority of the data directory it uses (by default), and yet it cannot create its subdirectory there.
If I try to fix the permissions so that Gitea can create its own new subdirectories, it reverts the changes before it would do anything else, including creating the new subdirectories.
@swang-harbin commented on GitHub (Aug 18, 2022):
@mpeter50 First of all,thanks for your reply.
"Repository Root Path" and "Run As Username" are both on the Initial Configuration page for port 3000:
)
And the access permissions of the /var/lib/gitea directory are:
And systemd unit file copied from here
I found instructions for [git].HOME here, but it still gives the same error after I configure
APP_DATA_PATH=/var/lib/giteain the Environment in the systemd unit fileAt the same time, after I set Environment to
Environment="USER=gitea HOME=/var/lib/gitea/ GITEA_WORK_DIR=/var/lib/gitea/"orEnvironment="USER=gitea HOME=/var/lib/gitea/ GITEA_WORK_DIR=/var/lib/gitea/ APP_DATA_PATH=/var/lib/gitea", it still gives the same error@lunny commented on GitHub (Aug 18, 2022):
Could you run
./gitea doctorto check if there is any error hints?@wxiaoguang commented on GitHub (Aug 18, 2022):
There are many different voices here and some are caused by different problems.
IMO most of the problems are not related to Gitea itself, but related to the environment.
I will provide a summary for various "permission" problems:
id the-user-name. And you can google (ps show uid/username) to show a process's uid or username (eg:ps aux, it may differ if you are using busybox). Docker users should check them inside the containersetting(although document said so ...). You can just set a service's user correctly byEnvironment="USER=giteacould be incorrectUser=xxxps auxshow the same user as the thels -linside the container. In some cases there could be a docker (rare) bug that makes the permissions messy..sshand related directories/files have the correct permission, otherwise OpenSSH won't start or work (also not related to Gitea directly)In short, in most cases permission problems are related to the environment, understand your environment and tune the permissions carefully (maybe in the future Gitea can provide a tool to help to check the environment)
If you believe there is a bug, please report: What's the username and uid are for Gitea process, what are the filesystem permissions(owner/mod) for the Gitea's custom/data and related directories/files. If you are running Gitea with docker, please collect these information inside the docker container.
@wxiaoguang commented on GitHub (Aug 18, 2022):
@swang-harbin
If you see
The repository root path is invalid: mkdir /var/lib/gitea: read-only file system., please use sudo to switch your command line user togiteato test if you can do something likemkdir /var/lib/gitea/test-dir. It's highly likely your filesystem can not be written correctly (especially when you are using a Router or NAS device), or your Gitea process is running as a different user.Or, you could try to use another directory for Gitea, eg:
mkdir /data/gitea; chown ... /data/giteathen use it.@swang-harbin commented on GitHub (Aug 18, 2022):
@lunny
I run
gitea doctor,and it prints the error below@swang-harbin commented on GitHub (Aug 18, 2022):
@wxiaoguang
I see from here that some environment variables need to be specified at runtime, so I use
USER=gitea USERNAME=gitea HOME=/home/gitea/ GITEA_WORK_DIR=/home/gitea/ gitea webto start, but its print information is still start with/var/snap/giteaIt can launch the configuration page.I use its default repository root path:
/var/snap/gitea/common/data/gitea-repositories,its error message becomes:Failed to save configuration: mkdir /var/snap/gitea/common/conf: permission denied.If I change
/var/snap/gitea/common/data/gitea-repositoriesto/home/gitea/common/data/gitea-repositories, it gives:The repository root path is invalid: mkdir /home/gitea/common: permission denied.But I can manually execute the following command successfully:
I think this error may be because I installed using snap, maybe I should use docker.
@lunny commented on GitHub (Aug 18, 2022):
Looks like your current user have no write permissions to the log directory.
@mpeter50 commented on GitHub (Aug 18, 2022):
@lunny
Do you say this to me or to swang-harbin?
If to me, is it ok to try that in my Gitea 1.16.5 container, or should I use the 1.17.0 container to execute this command?
@wxiaoguang
I have ran the following commands inside the Gitea container, while it is running with version 1.16.5:
ps cannot print the UID of processes as it seems the busybox of the container has a minimal version of it, so I used stat instead.
I currently don't have any program that manages backups or similar tasks.
If you want, I may try to install the audit tools on this system and set up detection for file permission changes to see what actually makes the changes. Or rather in the container, probably that would make more sense.
I do, but it is only involved in starting the Docker daemon. The containers are managed by docker-compose.
Do you mean that both of the mentioned commands need to be run in the container?
If so, the user names are matching.
Thanks for letting me know, the ownership of that directory was weird to me too, but didn't know what it should be. I'll let it alone for now, as I don't use it, and I think that feature has been removed from 1.17 anyway.
In my opinion I have already tried to tune the permissions carefully, but my tunings were reverted as soon as I started the Gitea container.
I have included these near the top of this comment, in my response to your first and second points.
@wxiaoguang commented on GitHub (Aug 18, 2022):
@mpeter50 This issue has became very long, I am not sure whether your problem has been resolved.
My first thought about your original problem is that the
customdirectory didn't have correct mode, it wasdr-x------, it's not writable, then it couldn't be written by Gitea correctly. Gitea expects that thecustomdirectory should be writable. And during the startup, Gitea may create directories under thecustomdirectory automatically.Maybe you could do
sudo chmod 0700 customto fix the problem.@wxiaoguang commented on GitHub (Aug 18, 2022):
What are reverted? If you mean that you can not make the
customdirectory writable, then it's highly likely caused by Docker's UID/GID mapping behavior (another long story, especially for users with CIFS/SMB/Windows storage).@zeripath commented on GitHub (Aug 18, 2022):
@swang-harbin:
Whilst the error message is very unfriendly and should be fixed, you should read it and then think a bit more instead of throwing your hands up.
What is the problem?
The doctor command is panicking with
Failed to create sublogger (doctor): open doctor.log: permission deniedWhat does that mean?
The doctor command cannot write to doctor.log in its current directory
How can this be solved?
Can the doctor command change where it logs?
Look at the help sheet for the command online or by running:
What does that say?
So how can I change the log file location?
Add the
--log-file "-"option to the command e.g.:@mpeter50 commented on GitHub (Aug 18, 2022):
@wxiaoguang
I agree, multiple people have been replying with different problems. My issue has not been resolved, I'm still running 1.16.5, and I would like to update to 1.17.
Yes, I understand that.
I have tried to manually add write permissions for the owner of the folder with chmod, but as soon as I start the Gitea container, the write permission gets revoked for some reason.
I meant this, yes. The permissions of the
customdirectory get changed fromdrwx------todr-x------.I don't use network storage for any directories of Gitea, everything is stored on the root partition of the host system, which is a USB connected portable hard drive.
I'll try to look up this UID/GID remapping behavior, though could you please give me soime pointers? An article would do. I request this to make sure we are on the same page.
@mpeter50 commented on GitHub (Aug 18, 2022):
If you mean this feature of Docker, I have been using it for something else earlier, but currently it is disabled.
To make sure that this is how it is actually, inside the container I see the same UIDs as the owner of the custom, git and ssh directories, as I see outside of the container, looking at my docker volumes:
Inside the container:
On the host system:
The relevant volume mapping in the docker-compose file:
@wxiaoguang commented on GitHub (Aug 18, 2022):
It really depends a lot of facts. Docker has root and rootless version. There doesn't seem to be an official document for it, I just searched and tried by myself before. So, the following information may not be accurate, just for your information.
For docker-with-root, the UID/GID/mode are stored with the file on the file system. I guess you are using the docker-with-root image. For docker-rootless, the UID/GID/mode are stored with xattr or NTFS extended attribute. Docker for Windows has more complex behaviors, depending on which backend is used (WSL2 or not), it's off-topic for this problem.
In my environment, the directories looks like this:
Then the question is, why your
customdirectory always has thedr-x------mode.I think there could be some tests to try (if you have time ...)
chmod 0700 customon the host to see whether the mode can be changed. If no, then that's the root problem (filesystem).custominside the simple container is correct, then stop the container to see whether the mode is still correct on the host.customto the production Gitea container and start. If the mode becomes incorrect again, then it's the Gitea docker image or program problem.@mpeter50 commented on GitHub (Aug 18, 2022):
@wxiaoguang thanks, I'll try these tests soon.
@mpeter50 commented on GitHub (Aug 18, 2022):
Oh, one question. I should do the with-Gitea parts of the test with the 1.17 image, right?
That is, the last test.
@wxiaoguang commented on GitHub (Aug 18, 2022):
You could try it with 1.16.x first to see whether the behavior differs, in case it's a regression bug for 1.17? 😂
If you only has 1.17 database, only 1.17 is also fine, at least we can know the problem
@chris-fj commented on GitHub (Aug 18, 2022):
@mpeter50 regarding to the question you asked me, yes,
gituser's UID is 116 and GID is 123@mpeter50 commented on GitHub (Aug 19, 2022):
The tests are done, here are the results.
Docker bug test
First I checked if just mounting to a docker container changes the permissions.
I gave write permissions to the owner on the
customdirectory:I started the container with this command:
(
gitea_gitea_datais a named volume stored at the location where I executed the previous commands)Checked the permissions inside too, and stopped the container:
Checked the permissions outside again:
Gitea bug test
Out of curiosity first I tried with the current container (1.16.5).
I checked if the permissions are still ok, before starting the container:
I started the container with docker-compose (if you're interested in the compose file, please let me know):
After the database and Gitea has finished starting up (~1 minute), I checked the permissions again:
The permissions have changed.
I also checked inside the container:
I also checked this again with 1.17.0.
I set the write permission again:
I changed the container image to start, and started the container:
When Gitea has started to start up and printed its first error messages, the permissions were changed again:
Conclusion
The strange behavior is connected to the Gitea container, but it looks it hasn't been introduced with 1.17.0, as the 1.16.5 container does this too.
@lunny commented on GitHub (Aug 19, 2022):
search all codebase with
os.MakeDirandos.MakeDirAll, couldn't find500permission. It's confusing.@wxiaoguang commented on GitHub (Aug 19, 2022):
In most cases, Gitea uses 0o777 + umask for the mode.
@mpeter50 Have you ever set some
umaskrelated things?I can reproduce the behavior by:
Maybe you are using umask = 277 , if you are using a mount point, check the mount's arguments and make it 022 and take a look at it if there are other arguments affecting the modes.
@mpeter50 commented on GitHub (Aug 19, 2022):
On the host OS I have the umask set to 022:
The container has this too: (for being able to execute this command, I started 1.16.5)
The directory where I store the data files of Gitea is stored on the root partition, and according to
/etc/fstabit is mounted withdefaults,noatimeoptions, orrw,noatimeaccording tomount(/dev/sda2 on / type ext4 (rw,noatime)).Otherwise I don't remember touching the umask setting on this system.
@wxiaoguang commented on GitHub (Aug 19, 2022):
Thank you for your time, I think I know the problem now.
I found this:
https://github.com/go-gitea/gitea/blob/main/docker/rootless/usr/local/bin/docker-setup.sh#L8
😂
@wxiaoguang commented on GitHub (Aug 19, 2022):
I proposed a PR for it:
But I haven't fully understand the problem at the moment.
@mpeter50 commented on GitHub (Sep 18, 2022):
Today I updated my instance to version 1.17.2, and everything seems fine.
Thanks again for looking into this!