From b57fcada3f4b7dfe74bfee65e44671366dd33644 Mon Sep 17 00:00:00 2001 From: Omer Tuchfeld Date: Mon, 25 Nov 2024 13:32:56 +0100 Subject: [PATCH] install: Fix broken `warn_on_host_root` check The `warn_on_host_root` check was broken when we added support for installing on already-ostree systems (but only for already-ostree systems). See https://github.com/containers/bootc/issues/907 The solution is to use the original user provided root_path for the fd passed to warn_on_host_root, rather than the modified one, as that will always match /proc/0/root's fsid (in ostree systems systemd is running with the deployment root as its root, and this is what we have mounted as /:/target) Signed-off-by: Omer Tuchfeld --- lib/src/install.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/src/install.rs b/lib/src/install.rs index 98857edf3..845379a63 100644 --- a/lib/src/install.rs +++ b/lib/src/install.rs @@ -1716,6 +1716,14 @@ pub(crate) async fn install_to_filesystem( } } + // Check to see if this happens to be the real host root + if !fsopts.acknowledge_destructive { + let root_path = &fsopts.root_path; + let rootfs_fd = Dir::open_ambient_dir(root_path, cap_std::ambient_authority()) + .with_context(|| format!("Opening target root directory {root_path}"))?; + warn_on_host_root(&rootfs_fd)?; + } + // If we're installing to an ostree root, then find the physical root from // the deployment root. let possible_physical_root = fsopts.root_path.join("sysroot"); @@ -1741,11 +1749,6 @@ pub(crate) async fn install_to_filesystem( rootfs_fd }; - // Check to see if this happens to be the real host root - if !fsopts.acknowledge_destructive { - warn_on_host_root(&rootfs_fd)?; - } - match fsopts.replace { Some(ReplaceMode::Wipe) => { let rootfs_fd = rootfs_fd.try_clone()?;