Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions crates/lib/src/bootc_composefs/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{
composefs_consts::{
COMPOSEFS_CMDLINE, ORIGIN_KEY_BOOT_DIGEST, ORIGIN_KEY_IMAGE, ORIGIN_KEY_MANIFEST_DIGEST,
TYPE1_ENT_PATH, TYPE1_ENT_PATH_STAGED, USER_CFG, USER_CFG_STAGED,
BLS_ENTRY_PREFIX,
},
install::EFI_LOADER_INFO,
parsers::{
Expand Down Expand Up @@ -303,7 +304,7 @@ fn get_sorted_type1_boot_entries_helper(
.to_str()
.ok_or(anyhow::anyhow!("Found non UTF-8 characters in filename"))?;

if !file_name.ends_with(".conf") {
if !(file_name.starts_with(BLS_ENTRY_PREFIX) && file_name.ends_with(".conf")) {
continue;
}

Expand Down Expand Up @@ -1091,8 +1092,16 @@ mod tests {
"loader/entries/random_file.txt",
"Random file that we won't parse",
)?;
tempdir.atomic_write("loader/entries/entry1.conf", entry1)?;
tempdir.atomic_write("loader/entries/entry2.conf", entry2)?;
tempdir.atomic_write(
"loader/entries/random_file.conf",
"Random file that we won't parse",
)?;
tempdir.atomic_write(
"loader/entries/bootc_random_file.txt",
"Random file that we won't parse",
)?;
tempdir.atomic_write("loader/entries/bootc_entry1.conf", entry1)?;
tempdir.atomic_write("loader/entries/bootc_entry2.conf", entry2)?;

let result =
get_sorted_type1_boot_entries_helper(&tempdir, true, false, Bootloader::Systemd)
Expand Down Expand Up @@ -1254,8 +1263,8 @@ mod tests {

tempdir.create_dir_all("loader/entries")?;
tempdir.create_dir_all("loader/entries.staged")?;
tempdir.atomic_write("loader/entries/active.conf", active_entry)?;
tempdir.atomic_write("loader/entries.staged/staged.conf", staged_entry)?;
tempdir.atomic_write("loader/entries/bootc_active.conf", active_entry)?;
tempdir.atomic_write("loader/entries.staged/bootc_staged.conf", staged_entry)?;

let result = list_type1_entries(&tempdir)?;
assert_eq!(result.len(), 2);
Expand Down
3 changes: 3 additions & 0 deletions crates/lib/src/composefs_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ pub(crate) const TYPE1_BOOT_DIR_PREFIX: &str = "bootc_composefs-";
/// The prefix for names of UKI and UKI Addons
pub(crate) const UKI_NAME_PREFIX: &str = TYPE1_BOOT_DIR_PREFIX;

/// The prefix for BLS file entries
pub(crate) const BLS_ENTRY_PREFIX: &str = "bootc_";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have TYPE1_BOOT_DIR_PREFIX for this

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to change that from bootc_composefs- -> bootc_ as it's used in other places. The format the BLS entry seems to follow is bootc_${ID}-${verity}-${index}.conf, though maybe I've misunderstood what the BLS entry is...


/// Prefix for OCI tags owned by bootc in the composefs repository.
///
/// Tags are created as `localhost/bootc-<manifest_digest>` to act as GC roots
Expand Down
28 changes: 28 additions & 0 deletions crates/lib/src/parsers/bls_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,34 @@ mod tests {
Ok(())
}

#[test]
fn test_boot_artifact_verity_efi_no_prefix() -> Result<()> {
let input = r#"
title Test
version 1
efi /EFI/boot/test.efi
"#;
let config = parse_bls_config(&input)?;

let result = config.get_verity();
assert!(result.is_err());
Ok(())
}

#[test]
fn test_boot_artifact_verity_efi_no_extension() -> Result<()> {
let input = r#"
title Test
version 1
efi /EFI/boot/test
"#;
let config = parse_bls_config(&input)?;

let result = config.get_verity();
assert!(result.is_err());
Ok(())
}

/// Test that Non-EFI boot_artifact_name fails when linux path has no parent
#[test]
fn test_boot_artifact_name_non_efi_no_parent() {
Expand Down
Loading