forge
Explore
Log in

Don't you dare go Hollow

forge

Clone
★ 0

0 watching0 forksRustAGPL-3.010.2 MiB3cdd794Tahinli14 minutes ago331 commits

mod.rs25 lines, 612 bytesHistoryRawDownload
1use std::fs;
2use std::process::Command;
3
4fn userns_available() -> bool {
5 let max = fs::read_to_string("/proc/sys/user/max_user_namespaces")
6 .ok()
7 .and_then(|s| s.trim().parse::<u64>().ok())
8 .unwrap_or(0);
9 if max == 0 {
10 return false;
11 }
12 Command::new("unshare")
13 .args(["--user", "--map-root-user", "true"])
14 .status()
15 .is_ok_and(|s| s.success())
16}
17
18pub fn can_run() -> bool {
19 if userns_available() {
20 true
21 } else {
22 eprintln!("skipping: unprivileged user namespaces are not available on this host");
23 false
24 }
25}