Skip to content

Commit c1474ce

Browse files
Use insecure UEFI for sdboot
Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 27fd63f commit c1474ce

3 files changed

Lines changed: 36 additions & 9 deletions

File tree

crates/xtask/src/tmt.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const DISTRO_CENTOS_9: &str = "centos-9";
3232
const COMPOSEFS_KERNEL_ARGS: [&str; 1] = ["--karg=enforcing=0"];
3333

3434
// Import the argument types from xtask.rs
35-
use crate::{RunTmtArgs, TmtProvisionArgs};
35+
use crate::{Bootloader, RunTmtArgs, TmtProvisionArgs};
3636

3737
/// Generate a random alphanumeric suffix for VM names
3838
fn generate_random_suffix() -> String {
@@ -111,7 +111,11 @@ const DEFAULT_SB_KEYS_DIR: &str = "target/test-secureboot";
111111
///
112112
/// For sealed images, secure boot keys must be present or an error is returned.
113113
#[context("Building firmware arguments")]
114-
fn build_firmware_args(sh: &Shell, image: &str) -> Result<Vec<String>> {
114+
fn build_firmware_args(
115+
sh: &Shell,
116+
image: &str,
117+
bootloader: &Option<Bootloader>,
118+
) -> Result<Vec<String>> {
115119
let is_sealed = is_sealed_image(sh, image)?;
116120
let sb_keys_dir = Utf8Path::new(DEFAULT_SB_KEYS_DIR);
117121

@@ -133,6 +137,8 @@ fn build_firmware_args(sh: &Shell, image: &str) -> Result<Vec<String>> {
133137
sb_keys_dir
134138
);
135139
}
140+
} else if matches!(bootloader, Some(Bootloader::Systemd)) {
141+
vec!["--firmware=uefi-insecure".into()]
136142
} else {
137143
Vec::new()
138144
};
@@ -310,7 +316,7 @@ pub(crate) fn run_tmt(sh: &Shell, args: &RunTmtArgs) -> Result<()> {
310316
println!("Detected distro: {}", distro);
311317
println!("Detected VARIANT_ID: {variant_id}");
312318

313-
let firmware_args = build_firmware_args(sh, image)?;
319+
let firmware_args = build_firmware_args(sh, image, &args.bootloader)?;
314320

315321
// Create tmt-workdir and copy tmt bits to it
316322
// This works around https://github.com/teemtee/tmt/issues/4062
@@ -697,7 +703,8 @@ pub(crate) fn tmt_provision(sh: &Shell, args: &TmtProvisionArgs) -> Result<()> {
697703
println!(" Image: {}", image);
698704
println!(" VM name: {}\n", vm_name);
699705

700-
let firmware_args = build_firmware_args(sh, image)?;
706+
// TODO: Send bootloader param here
707+
let firmware_args = build_firmware_args(sh, image, &None)?;
701708

702709
// Launch VM with bcvk
703710
// Use ds=iid-datasource-none to disable cloud-init for faster boot

crates/xtask/src/xtask.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub(crate) struct LocalRustDepsArgs {
7979

8080
/// Bootloader passed as --bootloader param for composefs builds
8181
// TODO: Find a better way to share this Enum between this and crates/lib
82-
#[derive(Debug, Clone, ValueEnum)]
82+
#[derive(Debug, Clone, ValueEnum, PartialEq, Eq)]
8383
pub enum Bootloader {
8484
/// grub as bootloader
8585
Grub,

tmt/tests/booted/test-install-to-filesystem-var-mount.sh

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ is_composefs=$(bootc status --json | jq '.status.booted.composefs')
120120

121121
if [[ $is_composefs != "null" ]]; then
122122
COMPOSEFS_BACKEND+=("--composefs-backend")
123+
tune2fs -O verity /dev/BL/var02
124+
tune2fs -O verity /dev/BL/root02
123125
fi
124126

125127
echo "${COMPOSEFS_BACKEND[@]}"
@@ -142,9 +144,27 @@ podman run \
142144

143145
# Verify the installation succeeded
144146
echo "Verifying installation..."
145-
test -d /var/mnt/target/ostree
146-
test -d /var/mnt/target/ostree/repo
147-
# Verify bootloader was installed (grub2 or loader for different configurations)
148-
test -d /var/mnt/target/boot/grub2 || test -d /var/mnt/target/boot/loader
147+
148+
if [[ $is_composefs == "null" ]]; then
149+
test -d /var/mnt/target/ostree
150+
test -d /var/mnt/target/ostree/repo
151+
152+
# Verify bootloader was installed (grub2 or loader for different configurations)
153+
test -d /var/mnt/target/boot/grub2 || test -d /var/mnt/target/boot/loader
154+
else
155+
test -d /var/mnt/target/composefs
156+
ls -lahR /var/mnt/target/boot
157+
158+
bootloader=$(bootc status --json | jq '.status.booted.composefs.bootloader' | tr '[:upper:]' '[:lower:]')
159+
160+
if [[ $bootloader == "grub" ]]; then
161+
test -d /var/mnt/target/boot/grub2 || test -d /var/mnt/target/boot/loader
162+
else
163+
test -d /var/mnt/target/boot/efi/EFI
164+
test -d /var/mnt/target/boot/efi/loader/entries
165+
fi
166+
167+
fi
168+
149169

150170
echo "Installation to-filesystem with separate /var mount succeeded!"

0 commit comments

Comments
 (0)