Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cap-primitives/src/rustix/fs/dir_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::ops::Deref;
#[cfg(unix)]
use std::os::unix::{ffi::OsStrExt, fs::OpenOptionsExt};
#[cfg(target_os = "wasi")]
use std::os::wasi::ffi::OsStrExt;
use std::os::wasi::{ffi::OsStrExt, fs::OpenOptionsExt};
use std::path::Path;
#[cfg(racy_asserts)]
use std::{ffi::OsString, os::unix::ffi::OsStringExt, path::PathBuf};
Expand Down Expand Up @@ -100,15 +100,15 @@ pub(crate) fn canonicalize_options() -> OpenOptions {
/// This function is not sandboxed and may trivially access any path that the
/// host process has access to.
pub(crate) fn open_ambient_dir_impl(path: &Path, _: AmbientAuthority) -> io::Result<fs::File> {
// This is for `std::fs`, so we don't have `dir_required`, so set
// `O_DIRECTORY` manually.
let flags = OFlags::DIRECTORY | target_o_path();

let mut options = fs::OpenOptions::new();
options.read(true);

#[cfg(not(target_os = "wasi"))]
options.custom_flags(flags.bits() as i32);
// This is for `std::fs`, so we don't have `dir_required`, so set
// `O_DIRECTORY` manually.
options.custom_flags((OFlags::DIRECTORY | target_o_path()).bits() as i32);
#[cfg(target_os = "wasi")]
options.directory(true);

options.open(&path)
}
Expand Down