-
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
Support creating symlinks outside elevated sessions #1188
Conversation
Oh, and I also decided to test for the build number of the first Insider build that supported the flag... |
…only) This patch fixes signature of the CreateSymbolicLinkW() function's declaratoin. The previous declaration claimed that said function returns a BOOL, while it really returns a BOOLEAN. This is not an academic distinction: BOOL is defined as an int (i.e. 32-bit) and BOOLEAN as an unsigned char (i.e. 8-bit). Therefore, the return value 0 (meaning, the least-significant 8 bits are all zero) could be mistaken to indicate a successful creation of the symbolic link (because the remaining 24 bits are undefined, and quite likely non-zero). Signed-off-by: Johannes Schindelin <[email protected]>
With Windows 10 Build 14972 in Developer Mode, a new flag is supported by CreateSymbolicLink() to create symbolic links even when running outside of an elevated session (which was previously required). This new flag is called SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE and has the numeric value 0x02. Previous Windows 10 versions will not understand that flag and return an ERROR_INVALID_PARAMETER, therefore we have to be careful to try passing that flag only when the build number indicates that it is supported. For more information about the new flag, see this blog post: https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10/ This patch is loosely based on the patch submitted by Samuel D. Leslie as git-for-windows#1184. Signed-off-by: Johannes Schindelin <[email protected]>
00813f0
to
dbba5f1
Compare
Looks good to me and nice pick-up on the return type of Only comment is I think it'd be nice to preserve the |
I agree. However, the header files available in Git for Windows' SDK do not even have that flag yet. So even if we bumped As to As the symbol's name has been mentioned in the code comment above, I am a bit less concerned about the magic-ness of the Thanks for the look-over! |
Excellent, thanks for the explanation as to the rationale. As for the missing flag, I addressed that in a separate patch a few days ago to the Mingw-w64 developers so it should be available in a future release (though doesn't solve the 80 columns per line issue, but indicating anyway just for reference). Thanks for merging. Looking forward to finally having 100% usable symlinks on Windows in Git! |
Git [now uses the flag introduced with Windows 10 Creators Update to create symbolic links without requiring elevated privileges](git-for-windows/git#1188) in Developer Mode. Signed-off-by: Johannes Schindelin <[email protected]>
Yesss! And thanks for all your help! |
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
Support creating symlinks outside elevated sessions
This Pull Request is intended to supersede #1184.
The main difference is that I fixed a rather serious bug (the return value was declared incorrectly, possibly fooling Git into believing that it could create a symbolic link when it really failed, and that really happened here during my tests), and that the file/directory flags are modified only once. I also use the
GetVersion()
API instead of the POSIX-yuname()
.