@@ -614,6 +614,7 @@ fn complete_pwgrp(rootfs: &Dir) -> Result<()> {
614614/// This is a pre-commit validation hook which ensures that the upcoming
615615/// users/groups entries are somehow sane. See treefile `check-passwd` and
616616/// `check-groups` fields for a description of available validation knobs.
617+ #[ context( "Validate users/groups refer to treefile check-passwd/check-groups" ) ]
617618pub fn check_passwd_group_entries (
618619 ffi_repo : & crate :: ffi:: OstreeRepo ,
619620 rootfs_dfd : i32 ,
@@ -630,8 +631,13 @@ pub fn check_passwd_group_entries(
630631
631632 // Parse entries in the upcoming commit content.
632633 let mut new_entities = PasswdEntries :: default ( ) ;
633- new_entities. add_passwd_content ( rootfs. as_raw_fd ( ) , "usr/lib/passwd" ) ?;
634- new_entities. add_group_content ( rootfs. as_raw_fd ( ) , "usr/lib/group" ) ?;
634+ if has_usrlib_passwd ( & rootfs) ? {
635+ new_entities. add_passwd_content ( rootfs. as_raw_fd ( ) , "usr/lib/passwd" ) ?;
636+ new_entities. add_group_content ( rootfs. as_raw_fd ( ) , "usr/lib/group" ) ?;
637+ } else {
638+ new_entities. add_passwd_content ( rootfs. as_raw_fd ( ) , "usr/etc/passwd" ) ?;
639+ new_entities. add_group_content ( rootfs. as_raw_fd ( ) , "usr/etc/group" ) ?;
640+ }
635641
636642 // Fetch entries from treefile and previous commit, according to config.
637643 // These are used as ground-truth by the validation steps below.
@@ -679,9 +685,11 @@ impl PasswdDB {
679685 pub ( crate ) fn populate_new ( rootfs : & Dir ) -> Result < Self > {
680686 let mut db = Self :: default ( ) ;
681687 db. add_passwd_content ( rootfs. as_raw_fd ( ) , "usr/etc/passwd" ) ?;
682- db. add_passwd_content ( rootfs. as_raw_fd ( ) , "usr/lib/passwd" ) ?;
683688 db. add_group_content ( rootfs. as_raw_fd ( ) , "usr/etc/group" ) ?;
684- db. add_group_content ( rootfs. as_raw_fd ( ) , "usr/lib/group" ) ?;
689+ if has_usrlib_passwd ( & rootfs) ? {
690+ db. add_passwd_content ( rootfs. as_raw_fd ( ) , "usr/lib/passwd" ) ?;
691+ db. add_group_content ( rootfs. as_raw_fd ( ) , "usr/lib/group" ) ?;
692+ }
685693 Ok ( db)
686694 }
687695
0 commit comments