()
| 56 | |
| 57 | #[cfg(unix)] |
| 58 | pub 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")] |
| 81 | const CGROUP_PIDS_MAX_PATH: &str = "/sys/fs/cgroup/pids.max"; |
no outgoing calls
no test coverage detected