Skip to content

Commit ba8f744

Browse files
authored
Merge pull request #290 from cgwalters/label-root
install: Ensure we label `/` (and `/boot`)
2 parents 024aa19 + d515c31 commit ba8f744

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)