Skip to content

Commit b57fcad

Browse files
committed
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 #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 <[email protected]>
1 parent 7c8121a commit b57fcad

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/src/install.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,6 +1716,14 @@ pub(crate) async fn install_to_filesystem(
17161716
}
17171717
}
17181718

1719+
// Check to see if this happens to be the real host root
1720+
if !fsopts.acknowledge_destructive {
1721+
let root_path = &fsopts.root_path;
1722+
let rootfs_fd = Dir::open_ambient_dir(root_path, cap_std::ambient_authority())
1723+
.with_context(|| format!("Opening target root directory {root_path}"))?;
1724+
warn_on_host_root(&rootfs_fd)?;
1725+
}
1726+
17191727
// If we're installing to an ostree root, then find the physical root from
17201728
// the deployment root.
17211729
let possible_physical_root = fsopts.root_path.join("sysroot");
@@ -1741,11 +1749,6 @@ pub(crate) async fn install_to_filesystem(
17411749
rootfs_fd
17421750
};
17431751

1744-
// Check to see if this happens to be the real host root
1745-
if !fsopts.acknowledge_destructive {
1746-
warn_on_host_root(&rootfs_fd)?;
1747-
}
1748-
17491752
match fsopts.replace {
17501753
Some(ReplaceMode::Wipe) => {
17511754
let rootfs_fd = rootfs_fd.try_clone()?;

0 commit comments

Comments
 (0)