Skip to content

Commit eb6bd01

Browse files
jeckersbcgwalters
authored andcommitted
install: Add final SELinux relabel of the physical root filesystem
Perform a full SELinux relabel pass over the physical root filesystem as the very last step before filesystem finalization. This ensures all files on the physical root have SELinux labels. Files that are already labeled (e.g. ostree deployment contents, composefs objects) are skipped since the relabel only acts on unlabeled files. Assisted-by: OpenCode (claude-opus-4-6) Signed-off-by: John Eckersberg <jeckersb@redhat.com>
1 parent edebe7b commit eb6bd01

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

crates/lib/src/install.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,18 @@ async fn install_to_filesystem_impl(
19841984
ostree_install(state, rootfs, cleanup).await?;
19851985
}
19861986

1987+
// As the very last step before filesystem finalization, do a full SELinux
1988+
// relabel of the physical root filesystem. Any files that are already
1989+
// labeled (e.g. ostree deployment contents, composefs objects) are skipped.
1990+
if let Some(policy) = state.load_policy()? {
1991+
tracing::info!("Performing final SELinux relabeling of physical root");
1992+
let mut path = Utf8PathBuf::from("");
1993+
crate::lsm::ensure_dir_labeled_recurse(&rootfs.physical_root, &mut path, &policy, None)
1994+
.context("Final SELinux relabeling of physical root")?;
1995+
} else {
1996+
tracing::debug!("Skipping final SELinux relabel (SELinux is disabled)");
1997+
}
1998+
19871999
// Finalize mounted filesystems
19882000
if !rootfs.skip_finalize {
19892001
let bootfs = rootfs.boot.as_ref().map(|_| ("boot", "boot"));

0 commit comments

Comments
 (0)