-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Add OpenOptions::exclusive #27217
Add OpenOptions::exclusive #27217
Conversation
a245dff
to
443a489
Compare
What are the effects of having Can you add a few more tests for the various flavors of flags as well? E.g. some cases like |
The man page says that the behavior of I can update the unix implementation to be a bit smarter and only tack on |
We currently have another PR (#26772) to handle some corner cases like this (which is why I ask). We still have yet to make a decision on that PR, though, although I personally favor the "let's just call into the OS" route over "let's add some verification on our end" route. |
It maps to O_EXCL on *nix and CREATE_NEW on Windows.
443a489
to
f1d6a50
Compare
As alexcrichton noted, how should differences between Windows and Unix be handled? Can we have some bikeshedding about the name? |
Besides requiring that a file does not exist, O_EXCL has a special rule on Unix for dealing with symlinks. This is not really a vulnerability on Windows, because it is somewhat difficult to create symlinks on it. Just to make the behaviour of symlinks with O_EXCL clear, this is what happens when trying to open
I think this should be mentioned in the documentation, something like: |
This will probably take a relatively similar outcome to #26772, and I wrote up some of the libs teams' thoughts here: #26772 (comment). In general it may be the case that |
I think I'll wait until #26772 resolves the behavior around implied flags and then update this. |
I'm going to close this in favor of the associated RFC (rust-lang/rfcs#1252) for |
It maps to O_EXCL on *nix and CREATE_NEW on Windows.
r? @alexcrichton