Skip to content

Commit b508e8b

Browse files
committed
install: Add BOOTC_SKIP_SELINUX_HOST_CHECK
We're going to investigate supporting installing SELinux-enabled targets from a SELinux-disabled host. This environment variable will allow bypassing the check. xref ostreedev/ostree#3151 Signed-off-by: Colin Walters <[email protected]>
1 parent 2ef5b3d commit b508e8b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,10 @@ jobs:
137137
--karg=foo=bar --disable-selinux --replace=alongside /target
138138
ls -al /boot/loader/
139139
sudo grep foo=bar /boot/loader/entries/*.conf
140+
# TODO fix https://github.com/containers/bootc/pull/137
141+
sudo chattr -i / /ostree/deploy/default/deploy/*
142+
sudo rm /ostree/deploy/default -rf
143+
sudo podman run --rm -ti --privileged --env BOOTC_SKIP_SELINUX_HOST_CHECK=1 --env RUST_LOG=debug -v /:/target -v /var/lib/containers:/var/lib/containers -v ./usr/bin/bootc:/usr/bin/bootc --pid=host --security-opt label=disable \
144+
quay.io/centos-bootc/fedora-bootc-dev:eln bootc install to-filesystem \
145+
--replace=alongside /target
146+
sudo ls -ldZ / /ostree/deploy/default/deploy/* /ostree/deploy/default/deploy/*/etc

lib/src/install.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,10 @@ pub(crate) fn reexecute_self_for_selinux_if_needed(
707707
let mut ret_did_override = false;
708708
// If the target state has SELinux enabled, we need to check the host state.
709709
let mut g = None;
710+
// We don't currently quite support installing SELinux enabled systems
711+
// from SELinux disabled hosts, but this environment variable can be set
712+
// to test it out anyways.
713+
let skip_check_envvar = "BOOTC_SKIP_SELINUX_HOST_CHECK";
710714
if srcdata.selinux {
711715
let host_selinux = crate::lsm::selinux_enabled()?;
712716
tracing::debug!("Target has SELinux, host={host_selinux}");
@@ -722,6 +726,11 @@ pub(crate) fn reexecute_self_for_selinux_if_needed(
722726
} else if override_disable_selinux {
723727
ret_did_override = true;
724728
println!("notice: Target has SELinux enabled, overriding to disable")
729+
} else if std::env::var_os(skip_check_envvar).is_some() {
730+
eprintln!(
731+
"Host kernel does not have SELinux support, but target enables it by default; {} is set, continuing anyways",
732+
skip_check_envvar
733+
);
725734
} else {
726735
anyhow::bail!(
727736
"Host kernel does not have SELinux support, but target enables it by default"

0 commit comments

Comments
 (0)