Skip to content

Filter out BLS entries not managed by bootc - #2243

Open
Dudecake wants to merge 4 commits into
bootc-dev:mainfrom
Dudecake:filter-custom-bls-entries
Open

Dudecake wants to merge 4 commits into
bootc-dev:mainfrom
Dudecake:filter-custom-bls-entries

Conversation

@Dudecake

Copy link
Copy Markdown

Fixes #2228

The cases that the tests in the last commit check cannot occur anymore because of the changes in get_sorted_type1_boot_entries_helper. If they're unneeded, I can drop the commit.

@bootc-bot
bootc-bot Bot requested a review from jeckersb June 10, 2026 12:59
@Dudecake
Dudecake force-pushed the filter-custom-bls-entries branch from dba7de3 to 9ade58e Compare June 10, 2026 13:08

@Johan-Liebert1 Johan-Liebert1 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This would work, but only for the first boot, and will probably fail on updates and switches as these entries won't be copied to the staged directory.

Comment thread crates/lib/src/composefs_consts.rs
@Dudecake

Copy link
Copy Markdown
Author

This would work, but only for the first boot, and will probably fail on updates and switches as these entries won't be copied to the staged directory.

Sad face. That makes this pretty useless as installing to a populated ESP works without issue, only bootc status and bootc update are broken.

Would the caller of list_type1_entries have to filter out these entries before calling get_verity on them?

@Johan-Liebert1

Copy link
Copy Markdown
Member

Would the caller of list_type1_entries have to filter out these entries before calling get_verity on them?

yes, and these need special treatment for updates/switches. Also, we need to make sure these appear last in the boot entries list etc etc. There are a few more cases that need to be handled

@Dudecake
Dudecake marked this pull request as draft June 11, 2026 04:46
@Dudecake
Dudecake force-pushed the filter-custom-bls-entries branch from 9ade58e to 80be97c Compare June 22, 2026 06:47
@Dudecake

Copy link
Copy Markdown
Author

I've been looking at this last- and previous weekend and attempting to have the caller filter these entries out would require a lot of changes as the original filename isn't included in the return value of list_type1_entries.

Creating unique filenames for entries using the same efi argument would be possible (but quite annoying) by also putting the title and/or options in the filename, so instead in create_staged_bls_entries copies any non-managed BLS entry to the staging directory.

@Dudecake
Dudecake marked this pull request as ready for review June 22, 2026 12:08
@bootc-bot
bootc-bot Bot requested a review from henrywang June 22, 2026 12:09
@Johan-Liebert1 Johan-Liebert1 added the ci/tier-1 Run CI for tier-1 OS (centos-10) only label Jun 22, 2026

@Johan-Liebert1 Johan-Liebert1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

State resilience test seems to be failing with

                        content: Error:   x Assertion failed.
                        content:     ,-[/var/tmp/tmt/bootc-tmt-mldew2as-tmt-plans-integration-plan-45-composefs-corruped-state-resilience/tmt/plans/integration/plan-45-composefs-corruped-state-resilience/discover/default-0/tests/tmt/tests/booted/test-composefs-corruped-state-resilience.nu:51:12]
                        content:  50 |     
                        content:  51 | ,->     assert (
                        content:  52 | |           journalctl F_MESSAGE_ID=d264f924dadb4c31bff0412107d391fb
                        content:  53 | |           | str contains $"No origin file for deployment bad-verity"
                        content:  54 | |->     )
                        content:     : `---- It is not true.
                        content:  55 |     
                        content:     `----

This is because we log a journal message when we encounter an entry that bootc doesn't own (doesn't start with our prefix). I think it's better now to change this error message as we are handling these entries

Comment thread crates/lib/src/bootc_composefs/backwards_compat/bcompat_boot.rs Outdated
Comment thread crates/lib/src/composefs_consts.rs
Comment thread crates/lib/src/bootc_composefs/backwards_compat/bcompat_boot.rs Outdated
@Dudecake

Copy link
Copy Markdown
Author

Nooo...

I'm not really sure how these entries end up here as list_bootloader_entries receives them from the changed get_sorted_type1_boot_entries_helper. Or is this test for grub with a user.cfg file?

@Dudecake
Dudecake force-pushed the filter-custom-bls-entries branch from 80be97c to 6307167 Compare July 6, 2026 06:32
staged_entries.atomic_write(filename, new_entry.to_string().as_bytes())?;
}

let original_entries = boot_dir.open_dir(TYPE1_ENT_PATH)?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is fine, but this is only for backwards compatibility stuff. The actual code for writing the staged entries would be somewhere in crates/lib/src/bootc_composefs/boot.rs

@Johan-Liebert1

Copy link
Copy Markdown
Member

CI errors are unrelated to this PR

@Dudecake
Dudecake force-pushed the filter-custom-bls-entries branch from 6307167 to 203a9f6 Compare July 20, 2026 06:38
@Dudecake

Copy link
Copy Markdown
Author

I'm not entirely happy with what I had to do to create a BootSetupType Upgrade in test_write_systemd_uki_config, but adding it to a (new) tmt test was a bit too intimidating

@Dudecake
Dudecake force-pushed the filter-custom-bls-entries branch from 203a9f6 to 4024f97 Compare August 24, 2026 06:27
@cgwalters

Copy link
Copy Markdown
Collaborator

@Johan-Liebert1 are you going to re-review this one? Only skimming at a high level it seems sane to me

@Johan-Liebert1

Copy link
Copy Markdown
Member

Ah, yes, this was buried deep in my GH notifications

@Johan-Liebert1 Johan-Liebert1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good overall. Needs a rebase to fix conflicts

.with_context(|| format!("Writing to {file_name}"))?;
}

let original_entries = boot_dir.open_dir(TYPE1_ENT_PATH)?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

}

#[cfg(test)]
mod tests {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These tests are fine to have, but having proper integration tests in the tmt/tests directory would be much nicer

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 has some difficulty setting up an environment where I can run the integration tests. The existing tests should be green in a clean fedora cloud image after installing the packages from the contributing document, but they're not...

I'll see if I can figure it out

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.

It was SELinux...

Not that I got much further after that. I was able to add a few checks to an existing tests and the custom entry is still there at the end, but the entries.staged directory doesn't seem to exist after the bootc upgrade... So there's probably something I'm not understanding/checking correctly

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It was SELinux...

that's always a tough one to find.

but the entries.staged directory doesn't seem to exist after the bootc upgrade

is the .staged directly not available after reboot, or before reboot? If it's not available before reboot, then yeah, there is something wrong here.

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.

Before reboot, so it should be there

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't see any obvious issues in your function. Are you sure you're checking in the right place?

Comment thread crates/lib/src/bootc_composefs/utils.rs Outdated
let entry = entry?;
let entry_name = entry.file_name()?;
if entry.file_type()?.is_file() && !entry_name.starts_with(BLS_ENTRY_PREFIX) {
original_entries.copy(entry_name.clone(), staged_entries, entry_name)?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ideally we'd want atomic writes here

Comment thread crates/lib/src/bootc_composefs/utils.rs Outdated

#[context("Staging non-managed BLS entry")]
pub(crate) fn stage_non_manged_bls_entries(boot_dir: &Dir, staged_entries: &Dir) -> Result<()> {
let original_entries = boot_dir.open_dir(TYPE1_ENT_PATH)?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe this should be the dir we pass and not the boot dir? We don't really need to boot dir per-se

@Dudecake
Dudecake force-pushed the filter-custom-bls-entries branch from e4f5df0 to 3ed9139 Compare October 23, 2026 20:32
Johan-Liebert1
Johan-Liebert1 previously approved these changes Oct 27, 2026

@Johan-Liebert1 Johan-Liebert1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good

@Dudecake

Copy link
Copy Markdown
Author

I didn't get around to fixing the integration test failures with ostree and the whitespace-only hunk in test-composefs-corrupted-state-resilience.nu past weekend + yesterday

I was planning on adding is_composefs to the ("/boot/loader/entries" | path exists) check tonight

Signed-off-by: Dudecake <ckoomen@ckoomen.eu>
Signed-off-by: Dudecake <ckoomen@ckoomen.eu>
Signed-off-by: Dudecake <ckoomen@ckoomen.eu>
Signed-off-by: Dudecake <ckoomen@ckoomen.eu>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/tier-1 Run CI for tier-1 OS (centos-10) only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding custom BLS entry blocks most bootc operations

4 participants