Skip to content

Commit 7997f57

Browse files
committed
install-to-filesystem: Verify target is a dir+mountpoint
Similarly to previous patch for `install to-disk`, verify that the target is a directory *and* that it's a mountpoint (we can't sanely support installing to a subdirectory of a filesystem). Signed-off-by: Colin Walters <[email protected]>
1 parent ffe46d8 commit 7997f57

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/src/install.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,13 +1123,22 @@ fn clean_boot_directories(rootfs: &Dir) -> Result<()> {
11231123

11241124
/// Implementation of the `bootc install to-filsystem` CLI command.
11251125
pub(crate) async fn install_to_filesystem(opts: InstallToFilesystemOpts) -> Result<()> {
1126-
// Gather global state, destructuring the provided options
1127-
let state = prepare_install(opts.config_opts, opts.target_opts).await?;
11281126
let fsopts = opts.filesystem_opts;
1129-
11301127
let root_path = &fsopts.root_path;
1128+
1129+
let st = root_path.symlink_metadata()?;
1130+
if !st.is_dir() {
1131+
anyhow::bail!("Not a directory: {root_path}");
1132+
}
11311133
let rootfs_fd = Dir::open_ambient_dir(root_path, cap_std::ambient_authority())
11321134
.with_context(|| format!("Opening target root directory {root_path}"))?;
1135+
if let Some(false) = ostree_ext::mountutil::is_mountpoint(&rootfs_fd, ".")? {
1136+
anyhow::bail!("Not a root mountpoint: {root_path}");
1137+
}
1138+
1139+
// Gather global state, destructuring the provided options
1140+
let state = prepare_install(opts.config_opts, opts.target_opts).await?;
1141+
11331142
match fsopts.replace {
11341143
Some(ReplaceMode::Wipe) => {
11351144
let rootfs_fd = rootfs_fd.try_clone()?;

0 commit comments

Comments
 (0)