From 26a0107f76ec74ba19236ced8f3fa60efecb693c Mon Sep 17 00:00:00 2001 From: Joseph Marrero Corchado Date: Thu, 29 Aug 2024 20:07:27 -0400 Subject: [PATCH] rust/src/bwrap.rs: check for fuse version 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: https://github.com/coreos/rpm-ostree/pull/5047 Co-authored-by: Colin Walters --- rust/src/bwrap.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/rust/src/bwrap.rs b/rust/src/bwrap.rs index a39e7524c1..c71a2fb3c2 100644 --- a/rust/src/bwrap.rs +++ b/rust/src/bwrap.rs @@ -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; @@ -114,6 +116,20 @@ impl RoFilesMount { } } +fn get_fusermount_path() -> Result { + 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() { @@ -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()