From 7e1207097bdf44083cfb94119f89059d30c3731e Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Sun, 4 Oct 2026 10:15:46 -0700 Subject: [PATCH] feat(boot): add the bls-strict-mode option Add --bls-strict-mode and bls-strict-mode in the options of sprout.toml. It does nothing yet; the behaviors it controls follow. --- crates/boot/src/main.rs | 7 +++++++ crates/boot/src/options.rs | 10 ++++++++++ crates/config/src/lib.rs | 13 +++++++++++++ 3 files changed, 30 insertions(+) diff --git a/crates/boot/src/main.rs b/crates/boot/src/main.rs index 519d08a..9c37e9d 100644 --- a/crates/boot/src/main.rs +++ b/crates/boot/src/main.rs @@ -199,6 +199,13 @@ fn run(reboot_on_error: &mut bool) -> Result<()> { .context("unable to set loader path in bootloader interface"), ); + // Strict mode can be asked for on the command line or in the configuration. + let mut options = options; + options.bls_strict_mode |= config.options.bls_strict_mode; + if options.bls_strict_mode { + info!("BLS strict mode is enabled"); + } + // Create the root context. let mut root = RootContext::new(loaded_image_path, timer, options); diff --git a/crates/boot/src/options.rs b/crates/boot/src/options.rs index 794c71c..74c6889 100644 --- a/crates/boot/src/options.rs +++ b/crates/boot/src/options.rs @@ -29,6 +29,8 @@ pub struct SproutOptions { pub menu_style: Option, /// Retains the boot console before boot. pub retain_boot_console: bool, + /// Makes Sprout follow the Boot Loader Specification and systemd-boot exactly. + pub bls_strict_mode: bool, } /// The default Sprout options. @@ -42,6 +44,7 @@ impl Default for SproutOptions { menu_timeout: None, menu_style: None, retain_boot_console: false, + bls_strict_mode: false, } } } @@ -60,6 +63,7 @@ impl SproutOptions { MenuTimeout, MenuStyle, RetainBootConsole, + BlsStrictMode, } // All the options for the Sprout executable. @@ -78,6 +82,8 @@ impl SproutOptions { .help_text("Boot menu style, basic, simple or graphical"), Opt::flag(ArgID::RetainBootConsole, &["--retain-boot-console"]) .help_text("Retain boot console before boot"), + Opt::flag(ArgID::BlsStrictMode, &["--bls-strict-mode"]) + .help_text("Follow the BLS specification and systemd-boot exactly"), ]); // Acquire the arguments as determined by the UEFI core. @@ -141,6 +147,10 @@ impl SproutOptions { // Retain the boot console before booting. result.retain_boot_console = true; } + ArgID::BlsStrictMode => { + // Follow the BLS specification and systemd-boot exactly. + result.bls_strict_mode = true; + } ArgID::Help => { let ctx = HelpWriterContext { options: &OPTIONS, diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 4dafce4..ee1c180 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -91,6 +91,12 @@ pub struct OptionsConfiguration { /// Enables autoconfiguration of Sprout based on the environment. #[serde(default)] pub autoconfigure: bool, + /// Makes Sprout follow the Boot Loader Specification and systemd-boot exactly where it + /// otherwise differs for convenience or safety. For example, the extended boot loader + /// partition is always read, a one-shot entry only sets the default entry, and entries with + /// missing files are hidden. See the README for everything it changes. + #[serde(rename = "bls-strict-mode", default)] + pub bls_strict_mode: bool, } /// The default configuration, which matches an empty configuration file. @@ -118,6 +124,7 @@ impl Default for OptionsConfiguration { menu_timeout: None, menu_style: Default::default(), autoconfigure: false, + bls_strict_mode: false, } } } @@ -164,6 +171,12 @@ mod tests { assert_eq!(default.options.autoconfigure, empty.options.autoconfigure); } + #[test] + fn bls_strict_mode_is_off_by_default() { + assert!(!RootConfiguration::default().options.bls_strict_mode); + assert!(!empty().options.bls_strict_mode); + } + #[test] fn menu_timeout_is_unset_by_default() { assert_eq!(RootConfiguration::default().options.menu_timeout, None);