()
| 423 | /// Convert /var for the current root to use systemd tmpfiles.d. |
| 424 | #[allow(unsafe_code)] |
| 425 | pub fn find_missing_tmpfiles_current_root() -> Result<TmpfilesResult> { |
| 426 | use uzers::cache::UsersSnapshot; |
| 427 | |
| 428 | let rootfs = Dir::open_ambient_dir("/", cap_std::ambient_authority())?; |
| 429 | |
| 430 | // See the docs for why this is unsafe |
| 431 | let usergroups = unsafe { UsersSnapshot::new() }; |
| 432 | |
| 433 | let existing_tmpfiles = read_tmpfiles(&rootfs)?.0; |
| 434 | |
| 435 | let mut prefix = PathBuf::from("/var"); |
| 436 | let mut tmpfiles = BTreeSet::new(); |
| 437 | let mut unsupported = Vec::new(); |
| 438 | convert_path_to_tmpfiles_d_recurse( |
| 439 | &TmpfilesConvertConfig { |
| 440 | users: &usergroups, |
| 441 | groups: &usergroups, |
| 442 | rootfs: &rootfs, |
| 443 | existing: &existing_tmpfiles, |
| 444 | readonly: true, |
| 445 | }, |
| 446 | &mut tmpfiles, |
| 447 | &mut unsupported, |
| 448 | &mut prefix, |
| 449 | )?; |
| 450 | Ok(TmpfilesResult { |
| 451 | tmpfiles, |
| 452 | unsupported, |
| 453 | }) |
| 454 | } |
| 455 | |
| 456 | /// Read all tmpfiles.d entries from a single directory |
| 457 | fn read_tmpfiles_from_dir( |
no test coverage detected