summaryrefslogtreecommitdiffstats
path: root/src/runner/runc/run.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/runner/runc/run.rs')
-rw-r--r--src/runner/runc/run.rs32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/runner/runc/run.rs b/src/runner/runc/run.rs
index 7e9a41c..09bd875 100644
--- a/src/runner/runc/run.rs
+++ b/src/runner/runc/run.rs
@@ -1,4 +1,9 @@
-use std::{fs::DirBuilder, io, process};
+use std::{
+ fs::{DirBuilder, File},
+ io,
+ path::{Path, PathBuf},
+ process,
+};
use nix::{
mount::{self, MsFlags},
@@ -7,7 +12,11 @@ use nix::{
};
use serde::{Deserialize, Serialize};
-use crate::{types::*, unshare, util::ToIOResult};
+use crate::{
+ types::*,
+ unshare,
+ util::{self, ToIOResult},
+};
use super::spec;
@@ -59,6 +68,23 @@ fn init_task() -> Result<(), Error> {
Ok(())
}
+fn output_filename(task: TaskRef) -> PathBuf {
+ Path::new("build/state").join(format!("{}.tar", task))
+}
+
+fn collect_output(task: TaskRef, task_def: Task) -> Result<(), io::Error> {
+ // Temporarily switch to the user running Rebel to get the right
+ // owner for the tar files
+ let file = {
+ let _setegid = util::setegid(unistd::Gid::from_raw(unshare::BUILD_GID))?;
+ let _seteuid = util::seteuid(unistd::Uid::from_raw(unshare::BUILD_UID))?;
+
+ File::create(output_filename(task))?
+ };
+
+ util::tar::pack(file, "build/tmp/runc/workdir", task_def.output.iter())?.sync_all()
+}
+
pub fn handle_task(task: TaskRef, task_def: Task) -> Result<(), Error> {
init_task()?;
@@ -89,5 +115,7 @@ pub fn handle_task(task: TaskRef, task_def: Task) -> Result<(), Error> {
String::from_utf8_lossy(output.stdout.as_slice()),
);
+ collect_output(task, task_def)?;
+
Ok(())
}