@@ -614,6 +614,7 @@ fn complete_pwgrp(rootfs: &Dir) -> Result<()> {
614
614
/// This is a pre-commit validation hook which ensures that the upcoming
615
615
/// users/groups entries are somehow sane. See treefile `check-passwd` and
616
616
/// `check-groups` fields for a description of available validation knobs.
617
+ #[ context( "Validate users/groups refer to treefile check-passwd/check-groups" ) ]
617
618
pub fn check_passwd_group_entries (
618
619
ffi_repo : & crate :: ffi:: OstreeRepo ,
619
620
rootfs_dfd : i32 ,
@@ -630,8 +631,13 @@ pub fn check_passwd_group_entries(
630
631
631
632
// Parse entries in the upcoming commit content.
632
633
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
+ }
635
641
636
642
// Fetch entries from treefile and previous commit, according to config.
637
643
// These are used as ground-truth by the validation steps below.
@@ -679,9 +685,11 @@ impl PasswdDB {
679
685
pub ( crate ) fn populate_new ( rootfs : & Dir ) -> Result < Self > {
680
686
let mut db = Self :: default ( ) ;
681
687
db. add_passwd_content ( rootfs. as_raw_fd ( ) , "usr/etc/passwd" ) ?;
682
- db. add_passwd_content ( rootfs. as_raw_fd ( ) , "usr/lib/passwd" ) ?;
683
688
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
+ }
685
693
Ok ( db)
686
694
}
687
695
0 commit comments