@@ -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 configuration" ) ]
617
618
pub fn check_passwd_group_entries (
618
619
ffi_repo : & crate :: ffi:: OstreeRepo ,
619
620
rootfs_dfd : i32 ,
@@ -630,8 +631,12 @@ 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
+ new_entities. add_passwd_content ( rootfs. as_raw_fd ( ) , "usr/etc/passwd" ) ?;
635
+ new_entities. add_group_content ( rootfs. as_raw_fd ( ) , "usr/etc/group" ) ?;
636
+ if has_usrlib_passwd ( & rootfs) ? {
637
+ new_entities. add_passwd_content ( rootfs. as_raw_fd ( ) , "usr/lib/passwd" ) ?;
638
+ new_entities. add_group_content ( rootfs. as_raw_fd ( ) , "usr/lib/group" ) ?;
639
+ }
635
640
636
641
// Fetch entries from treefile and previous commit, according to config.
637
642
// These are used as ground-truth by the validation steps below.
@@ -679,9 +684,11 @@ impl PasswdDB {
679
684
pub ( crate ) fn populate_new ( rootfs : & Dir ) -> Result < Self > {
680
685
let mut db = Self :: default ( ) ;
681
686
db. add_passwd_content ( rootfs. as_raw_fd ( ) , "usr/etc/passwd" ) ?;
682
- db. add_passwd_content ( rootfs. as_raw_fd ( ) , "usr/lib/passwd" ) ?;
683
687
db. add_group_content ( rootfs. as_raw_fd ( ) , "usr/etc/group" ) ?;
684
- db. add_group_content ( rootfs. as_raw_fd ( ) , "usr/lib/group" ) ?;
688
+ if has_usrlib_passwd ( & rootfs) ? {
689
+ db. add_passwd_content ( rootfs. as_raw_fd ( ) , "usr/lib/passwd" ) ?;
690
+ db. add_group_content ( rootfs. as_raw_fd ( ) , "usr/lib/group" ) ?;
691
+ }
685
692
Ok ( db)
686
693
}
687
694
0 commit comments