Ensure memtrack can load its eBPF programs: either run as root or hold the required file capabilities. Tries a one-time capability grant if neither holds, and bails if that fails.
()
| 77 | /// required file capabilities. Tries a one-time capability grant if neither |
| 78 | /// holds, and bails if that fails. |
| 79 | fn ensure_privileges() -> Result<()> { |
| 80 | if is_root_user() || has_memtrack_capabilities() { |
| 81 | return Ok(()); |
| 82 | } |
| 83 | |
| 84 | ensure_memtrack_capabilities()?; |
| 85 | |
| 86 | if has_memtrack_capabilities() { |
| 87 | return Ok(()); |
| 88 | } |
| 89 | |
| 90 | bail!( |
| 91 | "{MEMTRACK_COMMAND} needs elevated privileges to load its eBPF programs, but the \ |
| 92 | required capabilities could not be granted." |
| 93 | ); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | #[async_trait(?Send)] |
nothing calls this directly
no test coverage detected