-
-
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
Sys.isexecutable() unreliable on Windows #33212
Comments
@staticfloat I have a solution here, utilizing It can provide fine grain information on whether the file is:
I didn't really look at the logic here, but it seems much complex than using the Windows API directly:
Should I open a PR with the stated changes? |
@vtjnash, does this seem like a reasonable approach to you? |
If the docs are accurate then yes, this does seem reasonable to me. Good find, @musm! I think a small PoC would be really helpful to both myself and Jameson, and doesn't look too hard to put together. |
I can just open a PR with a working implementation which I am close to finishing |
This would require having the isexecutable check calling the AccessCheck function (https://docs.microsoft.com/en-us/windows/win32/secauthz/verifying-client-access-with-acls-in-c--). We could also implement this in |
@vtjnash which would you prefer I do? I know you have performance concerns about this, would you prefer that we do this in C whenever we call |
Oh, I don't care about performance of this. If you mean TOCTOU, this is instantly invalid, so it could never be never fast enough. Implementation in C might be easier because it takes so many arguments, or maybe not. |
Okay; I'll work up a patch to libuv and request your attention when it's ready |
WIP branches:
So far I'm having a hard time testing this; I actually am not sure what "executable" means in Windows; when I create normal files on Windows, right-click on them in Explorer and go to the |
What does git do on Windows? Or is that a meaningless question because it always runs in some UNIX emulation environment? The property we want (for ourselves—not sure if this is appropriate for libuv) is that when we unpack something, we can compute the git hash correctly. Frankly, we could make everything executable and just use some other bit of irrelevant metadata, but it seems like there must be a bit that also means the right thing to the operating system. |
Okay I've actually got it working, but now I have to fix |
Brilliant! |
Major progress. I bashed my head against the wall for a few hours, wondering why on earth certain API calls were failing, until I realized that half of the calls in win32 return The implementation is fairly straightforward: I augment
Party time right? Nope, not quite yet. Observe:
So far so good, however:
What happens is that the I could write a tool that iterates over the current ACL, finds conflicting entries, and modifies them, but I want to make sure that that is the correct way of doing it before chipping away at it, since it is tiresome and annoying. I am glad that this is half-way working though. So, current caveats for this solution:
|
A week of vacation did wonders for my desire to return to this, and I think I managed to get something fully working today: JuliaLang/libuv#6 I did end up writing the loops to iterate over all ACL entries, find |
…ee hashes We need this to be more general than just skipping Windows; if we are on Linux but using an NFS share or FAT32 filesystems, (for instance) we can run into the same issues. So we instead probe for the ability to have a sane `chmod()`/`isexecutable()` run, and if that fails, we do not bother to calculate git tree hashes. This should transparently start to calculate the proper git tree hashes on Windows once JuliaLang/julia#33212 is fixed
…ee hashes We need this to be more general than just skipping Windows; if we are on Linux but using an NFS share or FAT32 filesystems, (for instance) we can run into the same issues. So we instead probe for the ability to have a sane `chmod()`/`isexecutable()` run, and if that fails, we do not bother to calculate git tree hashes. This should transparently start to calculate the proper git tree hashes on Windows once JuliaLang/julia#33212 is fixed
…ee hashes We need this to be more general than just skipping Windows; if we are on Linux but using an NFS share or FAT32 filesystems, (for instance) we can run into the same issues. So we instead probe for the ability to have a sane `chmod()`/`isexecutable()` run, and if that fails, we do not bother to calculate git tree hashes. This should transparently start to calculate the proper git tree hashes on Windows once JuliaLang/julia#33212 is fixed
…ee hashes We need this to be more general than just skipping Windows; if we are on Linux but using an NFS share or FAT32 filesystems, (for instance) we can run into the same issues. So we instead probe for the ability to have a sane `chmod()`/`isexecutable()` run, and if that fails, we do not bother to calculate git tree hashes. This should transparently start to calculate the proper git tree hashes on Windows once JuliaLang/julia#33212 is fixed
…ee hashes We need this to be more general than just skipping Windows; if we are on Linux but using an NFS share or FAT32 filesystems, (for instance) we can run into the same issues. So we instead probe for the ability to have a sane `chmod()`/`isexecutable()` run, and if that fails, we do not bother to calculate git tree hashes. This should transparently start to calculate the proper git tree hashes on Windows once JuliaLang/julia#33212 is fixed
…ee hashes We need this to be more general than just skipping Windows; if we are on Linux but using an NFS share or FAT32 filesystems, (for instance) we can run into the same issues. So we instead probe for the ability to have a sane `chmod()`/`isexecutable()` run, and if that fails, we do not bother to calculate git tree hashes. This should transparently start to calculate the proper git tree hashes on Windows once JuliaLang/julia#33212 is fixed
Fixed by #35625? |
Seems so, but would be good to get @staticfloat's explicit approval. |
Yep! I'm calling this fixed! :D Hmmm, I don't think so. I think we decided that we're still not certain enough of the functionality here, and upstream has some notes on the implementation, so it may get tweaked. I'll remove it from the milestone. |
…ee hashes We need this to be more general than just skipping Windows; if we are on Linux but using an NFS share or FAT32 filesystems, (for instance) we can run into the same issues. So we instead probe for the ability to have a sane `chmod()`/`isexecutable()` run, and if that fails, we do not bother to calculate git tree hashes. This should transparently start to calculate the proper git tree hashes on Windows once JuliaLang/julia#33212 is fixed
The current implementation of
Sys.isexecutable()
is broken on Windows; it does not properly query the relevant ACLs, and simply returnstrue
if the file exists.It is necessary for us to emulate the proper behavior here as git tree hashing requires knowing if a file is executable or not, and the native
git
tools on Windows do "the right thing", so in order to hash to the same value we will need to do the right thing as well.The logic to do this is complex, but reducable. An example from cygwin is given here: https://github.com/Alexpux/Cygwin/blob/9c84bfd47922aad4881f80243320422b621c95dc/winsup/cygwin/sec_acl.cc#L636-L644
The text was updated successfully, but these errors were encountered: