Spawn bwrap and mirror its exit status instead of exec'ing into it

This commit is contained in:
2026-10-31 01:55:36 +01:00
parent c17e8c7c5d
commit 1c2f51ed3b
8 changed files with 89 additions and 9 deletions
+1
View File
@@ -7,3 +7,4 @@ mod mounts;
mod namespaces;
mod sandbox_info;
mod seccomp;
mod signals;
+33
View File
@@ -0,0 +1,33 @@
use std::os::unix::process::ExitStatusExt;
use crate::common::*;
#[test]
fn exit_code_of_entrypoint_is_returned() {
let status = Sandbox::new(&[])
.args(["--", "sh", "-c", "exit 42"])
.status()
.expect("agent-sandbox binary failed to execute");
assert_eq!(status.code(), Some(42));
}
#[test]
fn signal_death_of_entrypoint_becomes_exit_code() {
let status = Sandbox::new(&[])
.args(["--", "sh", "-c", "kill -TERM $$"])
.status()
.expect("agent-sandbox binary failed to execute");
assert_eq!(status.code(), Some(128 + libc::SIGTERM));
}
#[test]
fn signal_death_of_bwrap_is_mirrored() {
let status = Sandbox::new(&["--blacklist"])
.args(["--", "sh", "-c", "kill -KILL $PPID; sleep 5"])
.status()
.expect("agent-sandbox binary failed to execute");
assert_eq!(status.signal(), Some(libc::SIGKILL));
}