(capability: impl CompatCapability)
| 696 | /// [`prctl(PR_CAP_AMBIENT,PR_CAP_AMBIENT_IS_SET,…)`]: https://man7.org/linux/man-pages/man2/prctl.2.html |
| 697 | #[inline] |
| 698 | pub fn capability_is_in_ambient_set(capability: impl CompatCapability) -> io::Result<bool> { |
| 699 | let capset = capability.as_capability_set(private::Token).bits(); |
| 700 | if capset.count_ones() != 1 { |
| 701 | return Err(Errno::INVAL); |
| 702 | } |
| 703 | let cap = capset.trailing_zeros(); |
| 704 | |
| 705 | unsafe { |
| 706 | prctl_3args( |
| 707 | PR_CAP_AMBIENT, |
| 708 | PR_CAP_AMBIENT_IS_SET as *mut _, |
| 709 | // as *mut _ should be ptr::without_provenance_mut but our MSRV does not allow it. |
| 710 | cap as usize as *mut _, |
| 711 | ) |
| 712 | } |
| 713 | .map(|r| r != 0) |
| 714 | } |
| 715 | |
| 716 | const PR_CAP_AMBIENT_CLEAR_ALL: usize = 4; |
| 717 |
nothing calls this directly
no test coverage detected