Skip to content

Commit daddb84

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. 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 <omer@tuchfeld.dev>
1 parent 3604dbb commit daddb84

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/src/install.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,11 +1653,15 @@ pub(crate) async fn install_to_filesystem(
16531653
// the deployment root.
16541654
let possible_physical_root = fsopts.root_path.join("sysroot");
16551655
let possible_ostree_dir = possible_physical_root.join("ostree");
1656-
if possible_ostree_dir.exists() {
1656+
let original_root_path = if possible_ostree_dir.exists() {
16571657
tracing::debug!(
16581658
"ostree detected in {possible_ostree_dir}, assuming target is a deployment root and using {possible_physical_root}"
16591659
);
1660+
let original = fsopts.root_path.clone();
16601661
fsopts.root_path = possible_physical_root;
1662+
original
1663+
} else {
1664+
fsopts.root_path.clone()
16611665
};
16621666

16631667
// Get a file descriptor for the root path
@@ -1683,7 +1687,10 @@ pub(crate) async fn install_to_filesystem(
16831687

16841688
// Check to see if this happens to be the real host root
16851689
if !fsopts.acknowledge_destructive {
1686-
warn_on_host_root(&rootfs_fd)?;
1690+
let original_rootfs_fd =
1691+
Dir::open_ambient_dir(&original_root_path, cap_std::ambient_authority())
1692+
.with_context(|| format!("Opening target root directory {original_root_path}"))?;
1693+
warn_on_host_root(&original_rootfs_fd)?;
16871694
}
16881695

16891696
match fsopts.replace {

0 commit comments

Comments
 (0)