Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust/src/bwrap.rs: check for fuse version #5074

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could factor this out into a helper that we run once at startup, that would help us avoid the unwrap() but I'm fine with this as is too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's see if this fixes CI with the spec patch and I'll do a follow up with the startup part?

I guess it would go here

/// Validate basic assumptions on daemon startup.
?

.arg("-u")
.arg(tempdir.path())
.status()
Expand Down
Loading