@@ -119,6 +119,9 @@ pub(crate) struct InstallConfiguration {
119119 pub ( crate ) bootupd : Option < Bootupd > ,
120120 /// Bootloader to use (grub, systemd, none)
121121 pub ( crate ) bootloader : Option < Bootloader > ,
122+ /// Enforce that the containers-storage stack has a non-default
123+ /// (i.e. not `insecureAcceptAnything`) container image signature policy.
124+ pub ( crate ) enforce_container_sigpolicy : Option < bool > ,
122125}
123126
124127fn merge_basic < T > ( s : & mut Option < T > , o : Option < T > , _env : & EnvProperties ) {
@@ -203,6 +206,11 @@ impl Mergeable for InstallConfiguration {
203206 merge_basic ( & mut self . boot_mount_spec , other. boot_mount_spec , env) ;
204207 self . bootupd . merge ( other. bootupd , env) ;
205208 merge_basic ( & mut self . bootloader , other. bootloader , env) ;
209+ merge_basic (
210+ & mut self . enforce_container_sigpolicy ,
211+ other. enforce_container_sigpolicy ,
212+ env,
213+ ) ;
206214 if let Some ( other_kargs) = other. kargs {
207215 self . kargs
208216 . get_or_insert_with ( Default :: default)
@@ -876,3 +884,46 @@ bootloader = "grub"
876884 install. merge ( other, & env) ;
877885 assert_eq ! ( install. bootloader, Some ( Bootloader :: None ) ) ;
878886}
887+
888+ #[ test]
889+ fn test_parse_enforce_container_sigpolicy ( ) {
890+ let env = EnvProperties {
891+ sys_arch : "x86_64" . to_string ( ) ,
892+ } ;
893+
894+ // Test parsing true and false
895+ for ( input, expected) in [ ( "true" , true ) , ( "false" , false ) ] {
896+ let toml_str = format ! (
897+ r#"[install]
898+ enforce-container-sigpolicy = {input}
899+ "#
900+ ) ;
901+ let c: InstallConfigurationToplevel = toml:: from_str ( & toml_str) . unwrap ( ) ;
902+ assert_eq ! (
903+ c. install. unwrap( ) . enforce_container_sigpolicy. unwrap( ) ,
904+ expected
905+ ) ;
906+ }
907+
908+ // Default (not specified) is None
909+ let c: InstallConfigurationToplevel = toml:: from_str (
910+ r#"[install]
911+ root-fs-type = "xfs"
912+ "# ,
913+ )
914+ . unwrap ( ) ;
915+ assert ! ( c. install. unwrap( ) . enforce_container_sigpolicy. is_none( ) ) ;
916+
917+ // Test merging: last write wins
918+ let mut install: InstallConfiguration = toml:: from_str (
919+ r#"enforce-container-sigpolicy = false
920+ "# ,
921+ )
922+ . unwrap ( ) ;
923+ let other = InstallConfiguration {
924+ enforce_container_sigpolicy : Some ( true ) ,
925+ ..Default :: default ( )
926+ } ;
927+ install. merge ( other, & env) ;
928+ assert_eq ! ( install. enforce_container_sigpolicy. unwrap( ) , true ) ;
929+ }
0 commit comments