Skip to content

Commit 46f6dbf

Browse files
committed
cfs: Hard error on external kargs with UKIs
I thought about this with the cloud-init disablement for now with bcvk. It already works to just not enable `cloud-init.target` which we were already doing. Signed-off-by: Colin Walters <[email protected]>
1 parent 7daf9d3 commit 46f6dbf

File tree

6 files changed

+29
-19
lines changed

6 files changed

+29
-19
lines changed

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -856,11 +856,7 @@ pub(crate) fn setup_composefs_uki_boot(
856856
) -> Result<()> {
857857
let (root_path, esp_device, bootloader, is_insecure_from_opts, uki_addons) = match setup_type {
858858
BootSetupType::Setup((root_setup, state, ..)) => {
859-
if let Some(v) = &state.config_opts.karg {
860-
if v.len() > 0 {
861-
tracing::warn!("kargs passed for UKI will be ignored");
862-
}
863-
}
859+
state.require_no_kargs_for_uki()?;
864860

865861
let esp_part = esp_in(&root_setup.device_info)?;
866862

crates/lib/src/install.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,20 @@ impl State {
523523
Ok(())
524524
}
525525

526+
/// Return an error if kernel arguments are provided, intended to be used for UKI paths
527+
pub(crate) fn require_no_kargs_for_uki(&self) -> Result<()> {
528+
if self
529+
.config_opts
530+
.karg
531+
.as_ref()
532+
.map(|v| !v.is_empty())
533+
.unwrap_or_default()
534+
{
535+
anyhow::bail!("Cannot use externally specified kernel arguments with UKI");
536+
}
537+
Ok(())
538+
}
539+
526540
fn stateroot(&self) -> &str {
527541
self.config_opts
528542
.stateroot

crates/xtask/src/xtask.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,6 @@ fn check_dependencies(sh: &Shell) -> Result<()> {
531531
}
532532

533533
const COMMON_INST_ARGS: &[&str] = &[
534-
// We don't use cloud-init with bcvk right now, but it needs to be there for
535-
// testing-farm+tmt
536-
"--karg=ds=iid-datasource-none",
537534
// TODO: Pass down the Secure Boot keys for tests if present
538535
"--firmware=uefi-insecure",
539536
"--label=bootc.test=1",

hack/Containerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ COPY . /
99

1010
# An intermediate layer which caches the extended RPMS
1111
FROM localhost/bootc as extended
12-
# We support e.g. adding cloud-init
13-
ARG variant=
1412
# And this layer has additional stuff for testing, such as nushell etc.
1513
RUN --mount=type=bind,from=context,target=/run/context <<EORUN
1614
set -xeuo pipefail
1715
cd /run/context/
18-
./provision-derived.sh "$variant"
16+
./provision-derived.sh
1917
EORUN
2018

2119
# And the configs

hack/Containerfile.packit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ cp test-artifacts.repo /etc/yum.repos.d/
2929
dnf -y update bootc
3030
# Required by tmt avc checking after test
3131
dnf -y install audit
32-
./provision-derived.sh
32+
./provision-derived.sh cloudinit
3333

3434
# For test-22-logically-bound-install
3535
cp -a lbi/usr/. /usr

hack/provision-derived.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ set -xeu
44
# using it in our test suite because it's better than bash. First,
55
# enable EPEL to get it.
66

7+
cloudinit=0
8+
case ${1:-} in
9+
cloudinit) cloudinit=1 ;;
10+
"") ;;
11+
*) echo "Unhandled flag: ${1:-}" 1>&2; exit 1 ;;
12+
esac
13+
714
# Ensure this is pre-created
815
mkdir -p -m 0700 /var/roothome
916
mkdir -p ~/.config/nushell
@@ -39,25 +46,23 @@ esac
3946

4047
# Extra packages we install
4148
grep -Ev -e '^#' packages.txt | xargs dnf -y install
42-
dnf clean all
4349

4450
# Cloud bits
4551
cat <<KARGEOF >> /usr/lib/bootc/kargs.d/20-console.toml
4652
kargs = ["console=ttyS0,115200n8"]
4753
KARGEOF
48-
# And cloud-init stuff, unless we're doing a UKI which is always
49-
# tested with bcvk
50-
if test '!' -d /boot/EFI; then
54+
if test $cloudinit = 1; then
55+
dnf -y install cloud-init
5156
ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants
52-
fi
53-
54-
# Allow root SSH login for testing with bcvk/tmt
57+
# Allow root SSH login for testing with bcvk/tmt
5558
mkdir -p /etc/cloud/cloud.cfg.d
5659
cat > /etc/cloud/cloud.cfg.d/80-enable-root.cfg <<'CLOUDEOF'
5760
# Enable root login for testing
5861
disable_root: false
5962
CLOUDEOF
63+
fi
6064

65+
dnf clean all
6166
# Stock extra cleaning of logs and caches in general (mostly dnf)
6267
rm /var/log/* /var/cache /var/lib/{dnf,rpm-state,rhsm} -rf
6368
# And clean root's homedir

0 commit comments

Comments
 (0)