Skip to content

Conversation

@sunfishcode
Copy link
Member

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.

@sunfishcode
Copy link
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`
@sunfishcode
Copy link
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`.
@sunfishcode sunfishcode force-pushed the sunfishcode/maybe-dir-no-delete branch from 7abba16 to 2db844d Compare September 27, 2022 22:58
@sunfishcode sunfishcode merged commit b44ddeb into main Sep 29, 2022
@sunfishcode sunfishcode deleted the sunfishcode/maybe-dir-no-delete branch September 29, 2022 22:12
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants