fixed-spawners #36
@ -105,6 +105,8 @@ impl<'a> Spawner<'a> {
|
||||
let pipe = self.pipes.get_mut(s).unwrap().take_read()?;
|
||||
builder.keep_fd(&pipe);
|
||||
|
||||
builder.mount("/proc", "/proc").remount_proc();
|
||||
|
||||
let closure = || match self.pipe_trigger(pipe, entrypoint, name) {
|
||||
Ok(()) => exitcode::OK,
|
||||
Err(e) => {
|
||||
@ -129,6 +131,8 @@ impl<'a> Spawner<'a> {
|
||||
let socket = self.sockets.get_mut(s).unwrap().take_read()?;
|
||||
builder.keep_fd(&socket);
|
||||
|
||||
builder.mount("/proc", "/proc").remount_proc();
|
||||
|
||||
let closure = || match self.file_socket_trigger(socket, entrypoint, name) {
|
||||
Ok(()) => exitcode::OK,
|
||||
Err(e) => {
|
||||
@ -327,6 +331,10 @@ impl<'a> Spawner<'a> {
|
||||
Environment::DomainName(name) => {
|
||||
builder.set_domain_name(name);
|
||||
}
|
||||
|
||||
Environment::Procfs => {
|
||||
builder.mount("/proc", "/proc").remount_proc();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,6 +117,8 @@ pub enum Environment {
|
||||
|
||||
Hostname(String),
|
||||
DomainName(String),
|
||||
|
||||
Procfs,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Debug)]
|
||||
|
29
src/void.rs
29
src/void.rs
@ -33,6 +33,8 @@ pub struct VoidBuilder {
|
||||
|
||||
mounts: HashMap<PathBuf, PathBuf>,
|
||||
fds: HashSet<RawFd>,
|
||||
|
||||
remount_proc: bool,
|
||||
}
|
||||
|
||||
impl VoidBuilder {
|
||||
@ -42,6 +44,7 @@ impl VoidBuilder {
|
||||
domain_name: None,
|
||||
mounts: HashMap::new(),
|
||||
fds: HashSet::new(),
|
||||
remount_proc: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,6 +68,11 @@ impl VoidBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn remount_proc(&mut self) -> &mut Self {
|
||||
self.remount_proc = true;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn spawn(&mut self, child_fn: impl FnOnce() -> i32) -> Result<VoidHandle> {
|
||||
let mut args = CloneArgs::new(
|
||||
CloneFlags::CLONE_NEWCGROUP
|
||||
@ -252,12 +260,29 @@ impl VoidBuilder {
|
||||
fs::write(&dst, b"")?;
|
||||
}
|
||||
|
||||
// bind mount
|
||||
// rbind mount
|
||||
mount(
|
||||
Some(&src),
|
||||
&dst,
|
||||
Option::<&str>::None,
|
||||
MsFlags::MS_BIND,
|
||||
MsFlags::MS_BIND | MsFlags::MS_REC,
|
||||
Option::<&str>::None,
|
||||
)
|
||||
.map_err(|e| Error::Nix {
|
||||
msg: "mount",
|
||||
src: e,
|
||||
})?;
|
||||
}
|
||||
|
||||
// remount proc
|
||||
if self.remount_proc {
|
||||
debug!("remounting /proc`");
|
||||
|
||||
mount(
|
||||
Some("proc"),
|
||||
"/proc",
|
||||
Some("proc"),
|
||||
MsFlags::empty(),
|
||||
Option::<&str>::None,
|
||||
)
|
||||
.map_err(|e| Error::Nix {
|
||||
|
Loading…
Reference in New Issue
Block a user