3 ms·
In equivalent C++ on Windows, f is a file handle without delete share permissions so the act of successful opening the file locks out delete operations until th
by optimiz3 6y ago
In equivalent C++ on Windows, f is a file handle without delete share permissions so the act of successful opening the file locks out delete operations until the file handle is closed, preventing TTCTTOU issues. Am assuming Rust would be backed by the same is mechanism.
- Measter 6y agoOn Windows Rust calls out to `CreateFileW`[0], and by default uses the `FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE` share permission[1]. [0] https://github.com/rust-lang/rust/blob/master/library/std/src/sys/windows/fs.rs#L282-L300 https://github.com/rust-lang/rust/blob/master/library/std/sr... [1] https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.share_mode https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOption...
- optimiz3 6y agoThat's a design difference from C++ then, however even if the file is deleted the delete on Windows doesn't persist for existing open handles until the file is closed.