INNER CODE UNIT · Rust
is_home_or_ancestor
ouch-org/ouch · src/sandbox/mod.rs:101
pub fn is_home_or_ancestor(target: &Path) -> bool {
let Some(home) = std::env::var_os("HOME").map(PathBuf::from) else {
return false;
};
let Ok(home) = std::fs::canonicalize(&home) else {
return false;
};
let target = canonicalize_for_sandbox(target);
home == target || home.starts_with(&target)
}
/// True when the user turned the sandbox off by flag or by OUCH_NO_SANDBOX.
pub fn disabled_by_request(no_sandbox: bool) -> bool {
no_sandbox || std::env::var_os("OUCH_NO_SANDBOX").is_some()
}
// whether a sandbox can actually be enforced on this platform
pub fn available() -> bool {