@@ -288,8 +288,9 @@ 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
+ #[ serde( default ) ]
293
+ pub ( crate ) insecure : bool ,
293
294
}
294
295
295
296
#[ cfg( feature = "install-to-disk" ) ]
@@ -317,9 +318,11 @@ pub(crate) struct InstallToDiskOpts {
317
318
pub ( crate ) via_loopback : bool ,
318
319
319
320
#[ clap( long) ]
321
+ #[ serde( default ) ]
320
322
pub ( crate ) composefs_native : bool ,
321
323
322
324
#[ clap( flatten) ]
325
+ #[ serde( flatten) ]
323
326
pub ( crate ) composefs_opts : InstallComposefsOpts ,
324
327
}
325
328
@@ -608,17 +611,12 @@ impl FromStr for MountSpec {
608
611
impl InstallToDiskOpts {
609
612
pub ( crate ) fn validate ( & self ) -> Result < ( ) > {
610
613
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" ) ;
614
+ // Reject using --insecure without --composefs
615
+ if self . composefs_opts . insecure != false {
616
+ anyhow:: bail!( "--insecure must not be provided without --composefs" ) ;
614
617
}
615
618
}
616
619
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
620
Ok ( ( ) )
623
621
}
624
622
}
@@ -1592,7 +1590,7 @@ pub fn read_file<ObjectID: FsVerityHashValue>(
1592
1590
1593
1591
pub ( crate ) enum BootSetupType < ' a > {
1594
1592
/// For initial setup, i.e. install to-disk
1595
- Setup ( & ' a RootSetup ) ,
1593
+ Setup ( ( & ' a RootSetup , & ' a State ) ) ,
1596
1594
/// For `bootc upgrade`
1597
1595
Upgrade ,
1598
1596
}
@@ -1608,10 +1606,18 @@ pub(crate) fn setup_composefs_bls_boot(
1608
1606
let id_hex = id. to_hex ( ) ;
1609
1607
1610
1608
let ( root_path, cmdline_refs) = match setup_type {
1611
- BootSetupType :: Setup ( root_setup) => {
1609
+ BootSetupType :: Setup ( ( root_setup, state ) ) => {
1612
1610
// root_setup.kargs has [root=UUID=<UUID>, "rw"]
1613
1611
let mut cmdline_options = String :: from ( root_setup. kargs . join ( " " ) ) ;
1614
- cmdline_options. push_str ( & format ! ( " composefs={id_hex}" ) ) ;
1612
+
1613
+ match & state. composefs_options {
1614
+ Some ( opt) if opt. insecure => {
1615
+ cmdline_options. push_str ( & format ! ( " composefs=?{id_hex}" ) ) ;
1616
+ }
1617
+ None | Some ( ..) => {
1618
+ cmdline_options. push_str ( & format ! ( " composefs={id_hex}" ) ) ;
1619
+ }
1620
+ } ;
1615
1621
1616
1622
( root_setup. physical_root_path . clone ( ) , cmdline_options)
1617
1623
}
@@ -1766,16 +1772,26 @@ pub(crate) fn setup_composefs_uki_boot(
1766
1772
id : & Sha256HashValue ,
1767
1773
entry : ComposefsBootEntry < Sha256HashValue > ,
1768
1774
) -> Result < ( ) > {
1769
- let ( root_path, esp_device) = match setup_type {
1770
- BootSetupType :: Setup ( root_setup) => {
1775
+ let ( root_path, esp_device, is_insecure_from_opts) = match setup_type {
1776
+ BootSetupType :: Setup ( ( root_setup, state) ) => {
1777
+ if let Some ( v) = & state. config_opts . karg {
1778
+ if v. len ( ) > 0 {
1779
+ tracing:: warn!( "kargs passed for UKI will be ignored" ) ;
1780
+ }
1781
+ }
1782
+
1771
1783
let esp_part = root_setup
1772
1784
. device_info
1773
1785
. partitions
1774
1786
. iter ( )
1775
1787
. find ( |p| p. parttype . as_str ( ) == ESP_GUID )
1776
1788
. ok_or_else ( || anyhow ! ( "ESP partition not found" ) ) ?;
1777
1789
1778
- ( root_setup. physical_root_path . clone ( ) , esp_part. node . clone ( ) )
1790
+ (
1791
+ root_setup. physical_root_path . clone ( ) ,
1792
+ esp_part. node . clone ( ) ,
1793
+ state. composefs_options . as_ref ( ) . map ( |x| x. insecure ) ,
1794
+ )
1779
1795
}
1780
1796
1781
1797
BootSetupType :: Upgrade => {
@@ -1788,7 +1804,7 @@ pub(crate) fn setup_composefs_uki_boot(
1788
1804
anyhow:: bail!( "Could not find parent device for mountpoint /sysroot" ) ;
1789
1805
} ;
1790
1806
1791
- ( sysroot, get_esp_partition ( & parent) ?. 0 )
1807
+ ( sysroot, get_esp_partition ( & parent) ?. 0 , None )
1792
1808
}
1793
1809
} ;
1794
1810
@@ -1809,7 +1825,27 @@ pub(crate) fn setup_composefs_uki_boot(
1809
1825
ComposefsBootEntry :: Type2 ( type2_entry) => {
1810
1826
let uki = read_file ( & type2_entry. file , & repo) . context ( "Reading UKI" ) ?;
1811
1827
let cmdline = uki:: get_cmdline ( & uki) . context ( "Getting UKI cmdline" ) ?;
1812
- let ( composefs_cmdline, _) = get_cmdline_composefs :: < Sha256HashValue > ( cmdline) ?;
1828
+ let ( composefs_cmdline, insecure) = get_cmdline_composefs :: < Sha256HashValue > ( cmdline) ?;
1829
+
1830
+ // If the UKI cmdline does not match what the user has passed as cmdline option
1831
+ // NOTE: This will only be checked for new installs and now upgrades/switches
1832
+ if let Some ( is_insecure_from_opts) = is_insecure_from_opts {
1833
+ match is_insecure_from_opts {
1834
+ true => {
1835
+ if !insecure {
1836
+ tracing:: warn!(
1837
+ "--insecure passed as option but UKI cmdline does not support it"
1838
+ )
1839
+ }
1840
+ }
1841
+
1842
+ false => {
1843
+ if insecure {
1844
+ tracing:: warn!( "UKI cmdline has composefs set as insecure" )
1845
+ }
1846
+ }
1847
+ }
1848
+ }
1813
1849
1814
1850
let boot_label = uki:: get_boot_label ( & uki) . context ( "Getting UKI boot label" ) ?;
1815
1851
@@ -1991,17 +2027,21 @@ fn setup_composefs_boot(root_setup: &RootSetup, state: &State, image_id: &str) -
1991
2027
anyhow:: bail!( "No boot entries!" ) ;
1992
2028
} ;
1993
2029
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
- }
2030
+ let boot_type = BootType :: from ( & entry) ;
2031
+
2032
+ match boot_type {
2033
+ BootType :: Bls => setup_composefs_bls_boot (
2034
+ BootSetupType :: Setup ( ( & root_setup, & state) ) ,
2035
+ repo,
2036
+ & id,
2037
+ entry,
2038
+ ) ?,
2039
+ BootType :: Uki => setup_composefs_uki_boot (
2040
+ BootSetupType :: Setup ( ( & root_setup, & state) ) ,
2041
+ repo,
2042
+ & id,
2043
+ entry,
2044
+ ) ?,
2005
2045
} ;
2006
2046
2007
2047
write_composefs_state (
@@ -2013,7 +2053,7 @@ fn setup_composefs_boot(root_setup: &RootSetup, state: &State, image_id: &str) -
2013
2053
signature : None ,
2014
2054
} ,
2015
2055
false ,
2016
- composefs_opts . boot ,
2056
+ boot_type ,
2017
2057
) ?;
2018
2058
2019
2059
Ok ( ( ) )
0 commit comments