Skip to content

Commit

Permalink
rust/src/bwrap.rs: check for fuse version
Browse files Browse the repository at this point in the history
We have been building with fuse but changed to fuse3  on:
https://src.fedoraproject.org/rpms/rpm-ostree/c/3c602a23787fd2df873c0b18df3133c9fec4b66a
However our code is just calling fuse's fusermount.
We are updating our spec and code based on the discusion on:
#5047

Co-authored-by: Colin Walters <[email protected]>
  • Loading branch information
jmarrero and cgwalters committed Sep 3, 2024
1 parent 04ebd25 commit 26a0107
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion rust/src/bwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use crate::cxxrsutil::*;
use crate::ffi::BubblewrapMutability;
use crate::normalization;
use anyhow::{Context, Result};
use camino::Utf8Path;
use camino::Utf8PathBuf;
use cap_std::fs::Dir;
use cap_std_ext::prelude::{CapStdExtCommandExt, CapStdExtDirExt};
use fn_error_context::context;
Expand Down Expand Up @@ -114,6 +116,20 @@ impl RoFilesMount {
}
}

fn get_fusermount_path() -> Result<Utf8PathBuf> {
let path = std::env::var("PATH").expect("PATH set");
let fusermount_binaries = ["fusermount", "fusermount3"];
for elt in path.split(':').map(Utf8Path::new) {
for bin in fusermount_binaries {
let target = elt.join(bin);
if target.try_exists()? {
return Ok(target);
}
}
}
anyhow::bail!("No fusermount path found")
}

impl Drop for RoFilesMount {
fn drop(&mut self) {
let tempdir = if let Some(d) = self.tempdir.take() {
Expand All @@ -122,7 +138,7 @@ impl Drop for RoFilesMount {
return;
};
// We need to unmount before letting the tempdir cleanup run.
let success = Command::new("fusermount")
let success = Command::new(get_fusermount_path().unwrap().to_string())
.arg("-u")
.arg(tempdir.path())
.status()
Expand Down

0 comments on commit 26a0107

Please sign in to comment.