-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fix clone within a directory whose parent isn't readable by the current user #2533
Conversation
When creating directories via `safe_create_leading_directories()`, we might encounter an already-existing directory which is not readable by the current user. To handle that situation, Git's code calls `stat()` to determine whether we're looking at a directory. In such a case, `CreateFile()` will fail, though, no matter what, and consequently `mingw_stat()` will fail, too. But POSIX semantics seem to still allow `stat()` to go forward. So let's call `mingw_lstat()` for the rescue if we fail to get a file handle due to denied permission in `mingw_stat()`, and fill the stat info that way. We need to be careful to not allow this to go forward in case that we're looking at a symbolic link: to resolve the link, we would still have to create a file handle, and we just found out that we cannot. Therefore, `stat()` still needs to fail with `EACCES` in that case. This fixes git-for-windows#2531. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@danthe1st @byNoobiYT could you test this? |
Oh well, I guess I'll merge it before v2.26.0-rc0 (which should have happened, but got delayed for some reason). |
Fix clone within a directory whose parent isn't readable by the current user
Fix clone within a directory whose parent isn't readable by the current user
Should we still test it? If so, is it possible to test it without Visual Studio? |
@danthe1st yes, please test it. You won't be able to compile it with Visual Studio unless you get the entire Git for Windows SDK, which far outweighs Visual Studio. But we do have snapshot builds for Unfortunately, the build failed, but the next build hopefully won't, and you should be able to test the latest snapshot. |
There you go: https://wingit.blob.core.windows.net/files/index.html. |
Git for Windows [can now clone into directories the current user can write to, even if they lack permission to even read the parent directory](git-for-windows/git#2533). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
I tested it with that snapshot and I get a different error (with a better error message) prompting me for username and password. When entering the credentials correctly, I get the following error:
( If I enter incorrect credentials, I get a normal |
@danthe1st hmm. Can you build Git for Windows from source? If so, could you start the command in the debugger and set a breakpoint at the location changed by this PR and investigate further? |
Fix clone within a directory whose parent isn't readable by the current user
Fix clone within a directory whose parent isn't readable by the current user
Fix clone within a directory whose parent isn't readable by the current user
I got a Bluescreen(actually a greenscreen) while compiling git for windows(master for now) saying |
I successfully compiled it but when cloning the repository(not even in the
( |
After adding the
However, I don't get it to work in the normal cmd because of missing DLLs. |
Hmm. That's strange. As to running in-place, yes, the common way is to use |
Oh! I think I could imagine that Git Credential-Manager might be the culprit. Because...
This seems to not be coming from Git directly, but from the Git Credential Manager! (I was wondering about that exception, we do not use exceptions in core Git...) Maybe you can try again in the SDK, after appending |
It does work (in the SDK) even if |
What I meant to say, I think that you see the failures because In other words, if you run However, I am really curious now: why does that Credential Helper come into play, anyway? It's not like the Hello-World.git repository is a private one. It does not need you to authenticate. Strange. Really strange. |
Yes, it does work with the option without a warning. But it didn't fail before (without the option), it was just showing the error. |
But note that it worked when I compiled it from |
The difference is that the snapshot version configures |
Yes, it works without the
|
Okay, so our work here is done, eh? :-) |
Fix clone within a directory whose parent isn't readable by the current user
Fix clone within a directory whose parent isn't readable by the current user
Fix clone within a directory whose parent isn't readable by the current user
Even if the patch looks like it has nothing to do with cloning (or for that matter, with creating leading directories), this fixes #2531.