Skip to content

Commit f484d79

Browse files
committed
Filter out BLS entries not managed by bootc
Signed-off-by: Dudecake <ckoomen@ckoomen.eu>
1 parent 32907fd commit f484d79

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

crates/lib/src/bootc_composefs/status.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crate::{
1919
composefs_consts::{
2020
COMPOSEFS_CMDLINE, ORIGIN_KEY_BOOT_DIGEST, ORIGIN_KEY_IMAGE, ORIGIN_KEY_MANIFEST_DIGEST,
2121
TYPE1_ENT_PATH, TYPE1_ENT_PATH_STAGED, USER_CFG, USER_CFG_STAGED,
22+
BLS_ENTRY_PREFIX,
2223
},
2324
install::EFI_LOADER_INFO,
2425
parsers::{
@@ -303,7 +304,7 @@ fn get_sorted_type1_boot_entries_helper(
303304
.to_str()
304305
.ok_or(anyhow::anyhow!("Found non UTF-8 characters in filename"))?;
305306

306-
if !file_name.ends_with(".conf") {
307+
if !(file_name.starts_with(BLS_ENTRY_PREFIX) && file_name.ends_with(".conf")) {
307308
continue;
308309
}
309310

@@ -1091,8 +1092,16 @@ mod tests {
10911092
"loader/entries/random_file.txt",
10921093
"Random file that we won't parse",
10931094
)?;
1094-
tempdir.atomic_write("loader/entries/entry1.conf", entry1)?;
1095-
tempdir.atomic_write("loader/entries/entry2.conf", entry2)?;
1095+
tempdir.atomic_write(
1096+
"loader/entries/random_file.conf",
1097+
"Random file that we won't parse",
1098+
)?;
1099+
tempdir.atomic_write(
1100+
"loader/entries/bootc_random_file.txt",
1101+
"Random file that we won't parse",
1102+
)?;
1103+
tempdir.atomic_write("loader/entries/bootc_entry1.conf", entry1)?;
1104+
tempdir.atomic_write("loader/entries/bootc_entry2.conf", entry2)?;
10961105

10971106
let result =
10981107
get_sorted_type1_boot_entries_helper(&tempdir, true, false, Bootloader::Systemd)
@@ -1254,8 +1263,8 @@ mod tests {
12541263

12551264
tempdir.create_dir_all("loader/entries")?;
12561265
tempdir.create_dir_all("loader/entries.staged")?;
1257-
tempdir.atomic_write("loader/entries/active.conf", active_entry)?;
1258-
tempdir.atomic_write("loader/entries.staged/staged.conf", staged_entry)?;
1266+
tempdir.atomic_write("loader/entries/bootc_active.conf", active_entry)?;
1267+
tempdir.atomic_write("loader/entries.staged/bootc_staged.conf", staged_entry)?;
12591268

12601269
let result = list_type1_entries(&tempdir)?;
12611270
assert_eq!(result.len(), 2);

crates/lib/src/composefs_consts.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ pub(crate) const TYPE1_BOOT_DIR_PREFIX: &str = "bootc_composefs-";
4848
/// The prefix for names of UKI and UKI Addons
4949
pub(crate) const UKI_NAME_PREFIX: &str = TYPE1_BOOT_DIR_PREFIX;
5050

51+
/// The prefix for BLS file entries
52+
pub(crate) const BLS_ENTRY_PREFIX: &str = "bootc_";
53+
5154
/// Prefix for OCI tags owned by bootc in the composefs repository.
5255
///
5356
/// Tags are created as `localhost/bootc-<manifest_digest>` to act as GC roots

0 commit comments

Comments
 (0)