On Windows, make maybe_dir(true) disable deletion and renaming.#277
Merged
sunfishcode merged 2 commits intomainfrom Sep 29, 2022
Merged
On Windows, make maybe_dir(true) disable deletion and renaming.#277sunfishcode merged 2 commits intomainfrom
maybe_dir(true) disable deletion and renaming.#277sunfishcode merged 2 commits intomainfrom
Conversation
Member
Author
|
#226 should obviate this, by avoiding the need to protect cap-std's path lookup from concurrent deletes or renames; this is a temporary workaround. |
sunfishcode
added a commit
to sunfishcode/wasmtime
that referenced
this pull request
Sep 27, 2022
`O_DIRECTORY` says that a directory is required, but `O_DIRECTORY` is not required for opening directories. To implement this on top of the current APIs, use `open_dir` to try to open a directory first, and then fall back to trying to open it as a file if that fails. In the future, we may be able to simplify this code even more, using [`maybe_dir`], which is needed to allow Windows to be able to open a directory, though it needs bytecodealliance/cap-std#277 for Windows. The testcase here is the testcase from bytecodealliance#4947. [`maybe_dir`]: https://docs.rs/cap-fs-ext/latest/cap_fs_ext/struct.OpenOptions.html#method.maybe_dir`
Member
Author
|
This needs a new rustix release. |
sunfishcode
added a commit
to sunfishcode/wasmtime
that referenced
this pull request
Sep 27, 2022
`O_DIRECTORY` says that a directory is required, but `O_DIRECTORY` is not required for opening directories. To implement this on top of the current APIs, use `open_dir` to try to open a directory first, and then fall back to trying to open it as a file if that fails. In the future, we may be able to simplify this code even more, using [`maybe_dir`], which is needed to allow Windows to be able to open a directory, though it needs bytecodealliance/cap-std#277 for Windows. The testcase here is the testcase from bytecodealliance#4947. [`maybe_dir`]: https://docs.rs/cap-fs-ext/latest/cap_fs_ext/struct.OpenOptions.html#method.maybe_dir`
Similar to `dir_options()`, on Windows, when `maybe_dir` is set, clear the share flag for deletion and remaining, to protect cap-std's sandboxed path lookup. And, add a coment to cap-fs-ext's documentation for `maybe_dir`.
7abba16 to
2db844d
Compare
sunfishcode
added a commit
to sunfishcode/wasmtime
that referenced
this pull request
Jan 23, 2023
`O_DIRECTORY` says that a directory is required, but `O_DIRECTORY` is not required for opening directories. To implement this on top of the current APIs, use `open_dir` to try to open a directory first, and then fall back to trying to open it as a file if that fails. In the future, we may be able to simplify this code even more, using [`maybe_dir`], which is needed to allow Windows to be able to open a directory, though it needs bytecodealliance/cap-std#277 for Windows. And, factor out flags that are incompatible with directories. This comes from: https://github.com/rvolosatovs/wasmtime/blob/5ffb7f8990d1562bf9a1b6b29e3faadc934d024f/crates/wasi-common/src/snapshots/preview_1.rs#L895-L898 The testcase here is the testcase from bytecodealliance#4947. [`maybe_dir`]: https://docs.rs/cap-fs-ext/latest/cap_fs_ext/struct.OpenOptions.html#method.maybe_dir` Co-authored-by: Roman Volosatovs <rvolosatovs@riseup.net> Co-authored-by: Harald Hoyer <harald@hoyer.xyz>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Similar to
dir_options(), on Windows, whenmaybe_diris set, clear the share flag for deletion and remaining, to protect cap-std's sandboxed path lookup.And, add a coment to cap-fs-ext's documentation for
maybe_dir.