Skip to content

Commit d515c31

Browse files
committed
install: Ensure we label / (and /boot)
This came out of a discussion with bootc-image-builder, which has this issue right now: osbuild/bootc-image-builder#149 As I noted in that issue, I think it's basically been working here because we always write to a real fresh filesystem, but let's be very explicit. There's a notable tricky bootstrapping we're solving here around "what's the label of `/`" because we know we are running the target OS as a container image already. Signed-off-by: Colin Walters <[email protected]>
1 parent 1fa75d0 commit d515c31

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/src/install.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,10 @@ async fn initialize_ostree_root_from_self(
445445
let rootfs = root_setup.rootfs.as_path();
446446
let cancellable = gio::Cancellable::NONE;
447447

448+
// Ensure that the physical root is labeled.
449+
// Another implementation: https://github.com/coreos/coreos-assembler/blob/3cd3307904593b3a131b81567b13a4d0b6fe7c90/src/create_disk.sh#L295
450+
state.lsm_label(rootfs, "/".into(), false)?;
451+
448452
// TODO: make configurable?
449453
let stateroot = STATEROOT_DEFAULT;
450454
Task::new_and_run(
@@ -453,6 +457,12 @@ async fn initialize_ostree_root_from_self(
453457
["admin", "init-fs", "--modern", rootfs.as_str()],
454458
)?;
455459

460+
// And also label /boot AKA xbootldr, if it exists
461+
let bootdir = rootfs.join("boot");
462+
if bootdir.try_exists()? {
463+
state.lsm_label(&bootdir, "/boot".into(), false)?;
464+
}
465+
456466
// Default to avoiding grub2-mkconfig etc., but we need to use zipl on s390x.
457467
// TODO: Lower this logic into ostree proper.
458468
let bootloader = if cfg!(target_arch = "s390x") {

tests/kolainst/install

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ EOF
4040
grep -Ee '^linux /boot/ostree' /var/mnt/loader/entries/*.conf
4141
umount /var/mnt
4242
echo "ok install"
43+
mount /dev/vda4 /var/mnt
44+
ls -dZ /var/mnt |grep ':root_t:'
45+
umount /var/mnt
4346

4447
# Now test install to-filesystem
4548
# Wipe the device

0 commit comments

Comments
 (0)