@@ -288,8 +288,8 @@ impl From<&ComposefsBootEntry<Sha256HashValue>> for BootType {
288
288
289
289
#[ derive( Debug , Clone , clap:: Parser , Serialize , Deserialize , PartialEq , Eq ) ]
290
290
pub ( crate ) struct InstallComposefsOpts {
291
- #[ clap( long, value_enum , default_value_t) ]
292
- pub ( crate ) boot : BootType ,
291
+ #[ clap( long, default_value_t) ]
292
+ pub ( crate ) insecure : bool ,
293
293
}
294
294
295
295
#[ cfg( feature = "install-to-disk" ) ]
@@ -608,17 +608,12 @@ impl FromStr for MountSpec {
608
608
impl InstallToDiskOpts {
609
609
pub ( crate ) fn validate ( & self ) -> Result < ( ) > {
610
610
if !self . composefs_native {
611
- // Reject using --boot without --composefs
612
- if self . composefs_opts . boot != BootType :: default ( ) {
613
- anyhow:: bail!( "--boot must not be provided without --composefs" ) ;
611
+ // Reject using --insecure without --composefs
612
+ if self . composefs_opts . insecure != false {
613
+ anyhow:: bail!( "--insecure must not be provided without --composefs" ) ;
614
614
}
615
615
}
616
616
617
- // Can't add kargs to UKI
618
- if self . composefs_opts . boot == BootType :: Uki && self . config_opts . karg . is_some ( ) {
619
- anyhow:: bail!( "Cannot pass kargs to UKI" ) ;
620
- }
621
-
622
617
Ok ( ( ) )
623
618
}
624
619
}
@@ -1592,7 +1587,7 @@ pub fn read_file<ObjectID: FsVerityHashValue>(
1592
1587
1593
1588
pub ( crate ) enum BootSetupType < ' a > {
1594
1589
/// For initial setup, i.e. install to-disk
1595
- Setup ( & ' a RootSetup ) ,
1590
+ Setup ( ( & ' a RootSetup , & ' a State ) ) ,
1596
1591
/// For `bootc upgrade`
1597
1592
Upgrade ,
1598
1593
}
@@ -1608,10 +1603,18 @@ pub(crate) fn setup_composefs_bls_boot(
1608
1603
let id_hex = id. to_hex ( ) ;
1609
1604
1610
1605
let ( root_path, cmdline_refs) = match setup_type {
1611
- BootSetupType :: Setup ( root_setup) => {
1606
+ BootSetupType :: Setup ( ( root_setup, state ) ) => {
1612
1607
// root_setup.kargs has [root=UUID=<UUID>, "rw"]
1613
1608
let mut cmdline_options = String :: from ( root_setup. kargs . join ( " " ) ) ;
1614
- cmdline_options. push_str ( & format ! ( " composefs={id_hex}" ) ) ;
1609
+
1610
+ match & state. composefs_options {
1611
+ Some ( opt) if opt. insecure => {
1612
+ cmdline_options. push_str ( & format ! ( " composefs=?{id_hex}" ) ) ;
1613
+ }
1614
+ None | Some ( ..) => {
1615
+ cmdline_options. push_str ( & format ! ( " composefs={id_hex}" ) ) ;
1616
+ }
1617
+ } ;
1615
1618
1616
1619
( root_setup. physical_root_path . clone ( ) , cmdline_options)
1617
1620
}
@@ -1766,16 +1769,26 @@ pub(crate) fn setup_composefs_uki_boot(
1766
1769
id : & Sha256HashValue ,
1767
1770
entry : ComposefsBootEntry < Sha256HashValue > ,
1768
1771
) -> Result < ( ) > {
1769
- let ( root_path, esp_device) = match setup_type {
1770
- BootSetupType :: Setup ( root_setup) => {
1772
+ let ( root_path, esp_device, is_insecure_from_opts) = match setup_type {
1773
+ BootSetupType :: Setup ( ( root_setup, state) ) => {
1774
+ if let Some ( v) = & state. config_opts . karg {
1775
+ if v. len ( ) > 0 {
1776
+ tracing:: warn!( "kargs passed for UKI will be ignored" ) ;
1777
+ }
1778
+ }
1779
+
1771
1780
let esp_part = root_setup
1772
1781
. device_info
1773
1782
. partitions
1774
1783
. iter ( )
1775
1784
. find ( |p| p. parttype . as_str ( ) == ESP_GUID )
1776
1785
. ok_or_else ( || anyhow ! ( "ESP partition not found" ) ) ?;
1777
1786
1778
- ( root_setup. physical_root_path . clone ( ) , esp_part. node . clone ( ) )
1787
+ (
1788
+ root_setup. physical_root_path . clone ( ) ,
1789
+ esp_part. node . clone ( ) ,
1790
+ state. composefs_options . as_ref ( ) . map ( |x| x. insecure ) ,
1791
+ )
1779
1792
}
1780
1793
1781
1794
BootSetupType :: Upgrade => {
@@ -1788,7 +1801,7 @@ pub(crate) fn setup_composefs_uki_boot(
1788
1801
anyhow:: bail!( "Could not find parent device for mountpoint /sysroot" ) ;
1789
1802
} ;
1790
1803
1791
- ( sysroot, get_esp_partition ( & parent) ?. 0 )
1804
+ ( sysroot, get_esp_partition ( & parent) ?. 0 , None )
1792
1805
}
1793
1806
} ;
1794
1807
@@ -1809,7 +1822,27 @@ pub(crate) fn setup_composefs_uki_boot(
1809
1822
ComposefsBootEntry :: Type2 ( type2_entry) => {
1810
1823
let uki = read_file ( & type2_entry. file , & repo) . context ( "Reading UKI" ) ?;
1811
1824
let cmdline = uki:: get_cmdline ( & uki) . context ( "Getting UKI cmdline" ) ?;
1812
- let ( composefs_cmdline, _) = get_cmdline_composefs :: < Sha256HashValue > ( cmdline) ?;
1825
+ let ( composefs_cmdline, insecure) = get_cmdline_composefs :: < Sha256HashValue > ( cmdline) ?;
1826
+
1827
+ // If the UKI cmdline does not match what the user has passed as cmdline option
1828
+ // NOTE: This will only be checked for new installs and now upgrades/switches
1829
+ if let Some ( is_insecure_from_opts) = is_insecure_from_opts {
1830
+ match is_insecure_from_opts {
1831
+ true => {
1832
+ if !insecure {
1833
+ tracing:: warn!(
1834
+ "--insecure passed as option but UKI cmdline does not support it"
1835
+ )
1836
+ }
1837
+ }
1838
+
1839
+ false => {
1840
+ if insecure {
1841
+ tracing:: warn!( "UKI cmdline has composefs set as insecure" )
1842
+ }
1843
+ }
1844
+ }
1845
+ }
1813
1846
1814
1847
let boot_label = uki:: get_boot_label ( & uki) . context ( "Getting UKI boot label" ) ?;
1815
1848
@@ -1991,17 +2024,21 @@ fn setup_composefs_boot(root_setup: &RootSetup, state: &State, image_id: &str) -
1991
2024
anyhow:: bail!( "No boot entries!" ) ;
1992
2025
} ;
1993
2026
1994
- let Some ( composefs_opts) = & state. composefs_options else {
1995
- anyhow:: bail!( "Could not find options for composefs" )
1996
- } ;
1997
-
1998
- match composefs_opts. boot {
1999
- BootType :: Bls => {
2000
- setup_composefs_bls_boot ( BootSetupType :: Setup ( & root_setup) , repo, & id, entry) ?
2001
- }
2002
- BootType :: Uki => {
2003
- setup_composefs_uki_boot ( BootSetupType :: Setup ( & root_setup) , repo, & id, entry) ?
2004
- }
2027
+ let boot_type = BootType :: from ( & entry) ;
2028
+
2029
+ match boot_type {
2030
+ BootType :: Bls => setup_composefs_bls_boot (
2031
+ BootSetupType :: Setup ( ( & root_setup, & state) ) ,
2032
+ repo,
2033
+ & id,
2034
+ entry,
2035
+ ) ?,
2036
+ BootType :: Uki => setup_composefs_uki_boot (
2037
+ BootSetupType :: Setup ( ( & root_setup, & state) ) ,
2038
+ repo,
2039
+ & id,
2040
+ entry,
2041
+ ) ?,
2005
2042
} ;
2006
2043
2007
2044
write_composefs_state (
@@ -2013,7 +2050,7 @@ fn setup_composefs_boot(root_setup: &RootSetup, state: &State, image_id: &str) -
2013
2050
signature : None ,
2014
2051
} ,
2015
2052
false ,
2016
- composefs_opts . boot ,
2053
+ boot_type ,
2017
2054
) ?;
2018
2055
2019
2056
Ok ( ( ) )
0 commit comments