use std::fs; use std::process::Command; fn userns_available() -> bool { let max = fs::read_to_string("/proc/sys/user/max_user_namespaces") .ok() .and_then(|s| s.trim().parse::().ok()) .unwrap_or(0); if max == 0 { return false; } Command::new("unshare") .args(["--user", "--map-root-user", "true"]) .status() .is_ok_and(|s| s.success()) } pub fn can_run() -> bool { if userns_available() { true } else { eprintln!("skipping: unprivileged user namespaces are not available on this host"); false } }