Skip to main content

safe_open_in

Function safe_open_in 

pub async fn safe_open_in(
    root: impl AsRef<Path>,
    path: impl AsRef<Path>,
) -> Result<File, Error>
Expand description

Open a file read-only, confined to within the trusted directory root.

path is treated as relative to root; absolute paths, .. traversal, reserved device names, smuggled prefixes, and symbolic links that resolve outside root are all rejected. root itself must exist.

Equivalent to OpenOptions::new().read(true).jail(root).open(path).