Expose the bwrap command line at /run/agent-sandbox inside every sandbox

This commit is contained in:
2026-09-02 16:09:46 +02:00
parent 9185d1fb26
commit c8f2d62b64
9 changed files with 193 additions and 16 deletions
+10
View File
@@ -373,6 +373,7 @@ fn blacklist_overlays_survive_absolute_var_run_symlink() {
// layout inside the sandbox to reproduce on any host.
let _guard = HostGlobsLock::for_scan();
let mut bwrap_args = build_bwrap_command(&["--blacklist", "--no-seccomp", "--", "true"]);
strip_command_line_bind(&mut bwrap_args);
inject_absolute_var_run_symlink(&mut bwrap_args);
let output = Command::new(&bwrap_args[0])
@@ -568,6 +569,15 @@ fn rand_suffix() -> String {
format!("{nanos:08x}")
}
// The bind reads from an fd that only exists in the agent-sandbox process.
fn strip_command_line_bind(bwrap_args: &mut Vec<String>) {
let start = bwrap_args
.iter()
.position(|a| a == "--ro-bind-data")
.expect("dry-run output should bind the bwrap command line");
bwrap_args.drain(start..start + 3);
}
fn inject_absolute_var_run_symlink(bwrap_args: &mut Vec<String>) {
assert_eq!(bwrap_args[1], "--ro-bind");
assert_eq!(bwrap_args[2], "/");