MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / harden_child_process

Function harden_child_process

crates/openshell-supervisor-process/src/process.rs:58–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

56
57#[cfg(unix)]
58pub fn harden_child_process() -> Result<()> {
59 use rustix::process::{Resource, Rlimit, setrlimit};
60
61 setrlimit(
62 Resource::Core,
63 Rlimit {
64 current: Some(0),
65 maximum: Some(0),
66 },
67 )
68 .map_err(|e| miette::miette!("Failed to disable core dumps: {e}"))?;
69
70 #[cfg(target_os = "linux")]
71 {
72 use rustix::process::{DumpableBehavior, set_dumpable_behavior};
73 set_dumpable_behavior(DumpableBehavior::NotDumpable)
74 .map_err(|e| miette::miette!("Failed to set PR_SET_DUMPABLE=0: {e}"))?;
75 }
76
77 Ok(())
78}
79
80#[cfg(target_os = "linux")]
81const CGROUP_PIDS_MAX_PATH: &str = "/sys/fs/cgroup/pids.max";

Callers 3

spawn_implMethod · 0.85
probe_hardened_childFunction · 0.85
enter_netns_and_sandboxFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected