-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Dockerfile: upgrade to git >= 2.36 and set safe.directory = * #19707
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
Conversation
Signed-off-by: Loïc Dachary <[email protected]>
@@ -206,6 +206,12 @@ func Init(ctx context.Context) error { | |||
SupportProcReceive = false | |||
} | |||
|
|||
if CheckGitVersionAtLeast("2.36") == nil { | |||
if err := checkAndSetConfig("safe.directory", "*", true); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have a comment here, explaining why this is chosen and the rationale of it being safe.
Otherwise I would already see the comments/issues/questions pouring in. of why we're doing this and why we're deliberately making Gitea insecure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like a windows only issue - so can we only set this on windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is described for windows but is not windows specific:
/tmp/a/b$ strace -e stat git log
stat("/usr/share/locale", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/tmp/a/b", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
stat("/tmp/a/b/.git", 0x7ffe70098e60) = -1 ENOENT (No such file or directory)
stat("/tmp/a", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
stat("/tmp/a/.git", 0x7ffe70098e60) = -1 ENOENT (No such file or directory)
stat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=139264, ...}) = 0
stat("/tmp/.git", 0x7ffe70098e60) = -1 ENOENT (No such file or directory)
stat("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/.git", 0x7ffe70098e60) = -1 ENOENT (No such file or directory)
fatal: not a git repository (or any of the parent directories): .git
+++ exited with 128 +++
I'm really not convinced about this. This problem is a configuration issue with people's Dockerfiles. Gitea needs to be the owner of its repositories. |
Please see the rationale here. |
I agree. There appear to be two different but related problems. One has a simple fix. The other is not yet fully understood and has been going on for a long time, apparently. |
@Gusted added the suggested comment. |
Copying my comment from elsewhere: I’m concerned about it targeting edge, could the appropriate version of git be backported to alpine 3.15? |
@zeripath these comments may answer your question. Copied some content here:
And
|
@wxiaoguang A gentle reminder that this PR originates from Loïc Dachary. |
Oh fine, let him ignore my comments. My comments are written for maintainers, not for him. I won't do anything to him, let him relax. Update: to explain more, since there are a lot of noises in #19455, so I just copied my comments which I think should be useful here, to answer zeripath's question, and for others to refer. |
@wxiaoguang please do not change the state of my comments without my consent. You may think it is off-topic and maybe I agree with you but please ask me first instead of doing that unilaterally. |
Fine. May I mark these 4 comments + 1 more your reply as |
This PR ignored to figure out the real reason why there are files owned by I like @wxiaoguang 's idea which is a final resolution to change the git configuration. But that idea looks like it's not conflicted with this one. Off topic, I think there is no reason to refuse a maintainer to review the PR if he has a real and reasonable review. If every action of maintainers need poster or commenter's allow, it will make maintainers work difficult. |
This fix looks good to me, but I'm only the intermediary. Since there is a disagreement I don't feel I can keep relaying this pull requests. |
See original merge request from Loïc Dachary @ forgefriends
See also https://discourse.gitea.io/t/upgrading-git-push-fails-due-to-changed-security-policy-safe-directory/5185/4 for discussion.
Fixes: #19455