diff options
-rw-r--r-- | crates/runner/src/tar.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/crates/runner/src/tar.rs b/crates/runner/src/tar.rs index 1fc4bbb..4bc343f 100644 --- a/crates/runner/src/tar.rs +++ b/crates/runner/src/tar.rs @@ -1,5 +1,4 @@ use std::{ - fs::File, io::{self, Read, Write}, os::unix::prelude::CommandExt, path::Path, @@ -23,7 +22,7 @@ use crate::paths; pub fn pack<W: Write, P: AsRef<Path>>(archive: &mut W, source: P) -> Result<()> { let (mut piper, pipew) = fs::pipe()?; - let exec_tar = |stdout: File| -> Result<()> { + let exec_tar = || -> Result<()> { // We are in our own mount namespace, so mounting into the shared ROOTFS_DIR is fine let mount_target = paths::join(&[paths::ROOTFS_DIR, paths::TASK_BUILDDIR]); mount::mount::<_, _, str, str>( @@ -47,7 +46,7 @@ pub fn pack<W: Write, P: AsRef<Path>>(archive: &mut W, source: P) -> Result<()> ".", ]) .stdin(Stdio::null()) - .stdout(stdout) + .stdout(pipew) .current_dir(paths::TASK_BUILDDIR) .env_clear() .env("PATH", "/usr/sbin:/usr/bin:/sbin:/bin") @@ -56,14 +55,10 @@ pub fn pack<W: Write, P: AsRef<Path>>(archive: &mut W, source: P) -> Result<()> process::exit(127); }; - let (pid, pipew) = unsafe { - ns::spawn(CloneFlags::CLONE_NEWNS, pipew, |pipew| { - exec_tar(pipew).unwrap() - }) - } - .context("Failed to run tar")?; + let pid = unsafe { ns::spawn(CloneFlags::CLONE_NEWNS, (), |()| exec_tar().unwrap()) } + .context("Failed to run tar")? + .0; - drop(pipew); let result = io::copy(&mut piper, archive).context("Failed to write TAR archive"); wait::waitpid(pid, None)? |