Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 1 addition & 29 deletions composefs-run/src/fuse.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fs;
use std::io::Read;
use std::os::fd::{AsFd, AsRawFd, FromRawFd};
use std::os::fd::FromRawFd;
use std::os::unix::process::CommandExt;
use std::path::Path;
use std::process::Command;
Expand All @@ -10,7 +10,6 @@ use clap::Parser;
use composefs::fsverity::{FsVerityHashValue, Sha256HashValue, Sha512HashValue};
use composefs::repository::{Repository, read_repo_algorithm};
use rustix::fs::{CWD, Mode, OFlags};
use rustix::mount::{FsMountFlags, MountAttrFlags};

/// Arguments for the internal FUSE server mode.
#[derive(Debug, Parser)]
Expand Down Expand Up @@ -67,33 +66,6 @@ pub fn spawn_server(repo_path: &Path, erofs_hex: &str, fuse_fd: i32) -> Result<(
Ok(())
}

/// Like composefs_fuse::mount_fuse() but without `allow_other`, which
/// requires /etc/fuse.conf `user_allow_other` or CAP_SYS_ADMIN in the
/// init user namespace. We don't need it since only our own process tree
/// accesses the mount.
/// TODO: fix upstream composefs_fuse::mount_fuse() to make allow_other
/// optional, then use that instead.
pub fn mount_rootless(dev_fuse: impl AsFd) -> Result<rustix::fd::OwnedFd> {
let fusefs = composefs::mount::FsHandle::open("fuse")?;
rustix::mount::fsconfig_set_flag(fusefs.as_fd(), "ro")?;
rustix::mount::fsconfig_set_flag(fusefs.as_fd(), "default_permissions")?;
rustix::mount::fsconfig_set_string(fusefs.as_fd(), "source", "composefs-fuse")?;
rustix::mount::fsconfig_set_string(fusefs.as_fd(), "rootmode", "040555")?;
rustix::mount::fsconfig_set_string(fusefs.as_fd(), "user_id", "0")?;
rustix::mount::fsconfig_set_string(fusefs.as_fd(), "group_id", "0")?;
rustix::mount::fsconfig_set_string(
fusefs.as_fd(),
"fd",
format!("{}", dev_fuse.as_fd().as_raw_fd()),
)?;
rustix::mount::fsconfig_create(fusefs.as_fd())?;
Ok(rustix::mount::fsmount(
fusefs.as_fd(),
FsMountFlags::FSMOUNT_CLOEXEC,
MountAttrFlags::empty(),
)?)
}

/// Run the FUSE server (called via --internal-fuse-serve).
pub fn run_server(args: &FuseServeArgs) -> Result<()> {
let repo_fd = rustix::fs::open(
Expand Down
4 changes: 3 additions & 1 deletion composefs-run/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ fn mount_rootfs_with_fuse(
let dev_fuse = composefs_fuse::open_fuse().context("Opening /dev/fuse")?;
let fuse_fd_num = dev_fuse.as_raw_fd();

let fuse_mount_fd = fuse::mount_rootless(&dev_fuse).context("Creating FUSE mount")?;
let fuse_mount_fd =
composefs_fuse::mount_fuse(&dev_fuse, &composefs_fuse::FuseMountOptions::default())
.context("Creating FUSE mount")?;

let erofs_hex = image.erofs_hex.as_deref().context("No composefs image")?;
fuse::spawn_server(repo_path, erofs_hex, fuse_fd_num)?;
Expand Down
Loading