-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
gitea and read-only filsystems #11855
Comments
We rely on |
Yes, but can we disable this method when the file already exists ? |
Just set the HOME environment variable as appropriate to somewhere that can be changed. |
No, because we don't know whether correct values are set or not. The fact that file exists tells us nothing. The |
My usecase happens in a container environment. A new version is introduced by creating a new container image, not updating the existing one. |
I tried to do an init container that sets everything and a container with It is a security issue as it forces to use a read-write filesystem for just a file that can easily be commmited in a git. Can we, at least, have an option to use |
@micheelengronne have you set the HOME environment variable appropriately? |
Changing the |
So, what can change is the content of |
I am sorry to be strict on that. But this is an absolute condition to make gitea run in security hardened infrastructures. Containers must work with read-only FS and read-only configurations and secrets. |
Right the issue is that Git is making the change to the file. We are limited in how we can tell Git to look for its .gitconfig. Git uses HOME to determine the global gitconfig which we use to set various global settings and to look up various things. So I ask again, have you tried setting the HOME variable to a mutable place? |
If that works then can consider if there is a place for using ROOT to artificially change the HOME for git etc. but without knowing that then we're likely leading down a blind alley and we might have to think about if we need to set things a different way eg. through the default args system |
To be sure we talk about the same thing. If I move Did I understand correctly ? In that way, configurations are not immutables and that will not pass hardened security tests. Why can't we have a way to include a |
No I mean just set the HOME environment variable when you run gitea |
But that will screw up my user directory. For instance, my user is
Then the init method should not try to write this file. Do you suggest, I move If it works that's better than nothing but that will still break the security hardening check as I try. |
That works but that's not really the best solution. It would be far better to test if the file exists with the correct values before trying to create it. If a gitea update occurs that change the file content, the CI job that creates the docker (podman) image would break so future compatibilities would be ensured by that way. |
BTW, the 2 first git executions do what I think is the correct way to do. Line 112 in 83e9ac5
They check if the values exist and they are the same than the ones provided and they execute the git command if one of these assertions is false. The problem is for these lines: Line 126 in 83e9ac5
Line 132 in 83e9ac5
Line 137 in 83e9ac5
They do not check so they always try to write. I am not fluent enough in go to do it myself right now. |
So any configuration in |
Fix go-gitea#11855 Signed-off-by: Andrew Thornton <[email protected]>
* Only write to global gitconfig if necessary Fix #11855 Signed-off-by: Andrew Thornton <[email protected]> * placate lint Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: techknowlogick <[email protected]>
I know that. But that was not the point. Anyway, thanks for the commit. |
* Only write to global gitconfig if necessary Fix go-gitea#11855 Signed-off-by: Andrew Thornton <[email protected]> * placate lint Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: techknowlogick <[email protected]>
Gitea wants to modify files even if they are present and with the content gitea wants to put in.
Therefore, Gitea breaks on read-only filesystems (like an hardened docker container.)
My problem is simple.
This method wants to modify a
.gitconfig
file:gitea/modules/git/git.go
Line 109 in 9a2e47b
It runs even if the
.gitconfig
file exists with the correct content.Is it possible to stop that behaviour ?
Thanks.
The text was updated successfully, but these errors were encountered: