diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 11:36:36 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 11:36:36 +0000 |
| commit | 3374ffd34921e1de414e8b07f69753113f5ba5f9 (patch) | |
| tree | ea60c89b4e80d9c690761eb6399f2ddcfad56daa /src/config.rs | |
| parent | bc8f069d18c5de3dee04ae303227a255248efc1e (diff) | |
| download | aur-build-3374ffd34921e1de414e8b07f69753113f5ba5f9.tar.gz aur-build-3374ffd34921e1de414e8b07f69753113f5ba5f9.zip | |
sandbox: ephemeral agent, wire protocol, and the hub's remote backend
The seam from the previous commits only had one body. This adds the
other one: a sandbox-agent binary that dials the hub (outbound
rendezvous — the hub never needs a route into an untrusted box), serves
Run/Put/Get frames over length-prefixed JSON, streams the child's
stdout/stderr as they fill, and dies — taking its child with it — when
the connection drops or its TTL expires. The TTL watchdog is the
backstop under every leak: hub crash, partition, a forgotten destroy.
Hub side, RemoteBackend implements the same SandboxBackend: acquire
waits for a dial-in and verifies the shared token and profile before a
lease exists; a vanished sandbox fails the step, which is already the
shape of an expired lease (I5), so the remote path adds no new failure
vocabulary. Run frames carry the hub's child environment, so the §16a
shim protocol reaches remote children exactly as local ones — which is
what makes the end-to-end test honest: a real build, real frames, real
log streaming into the SSE-tailed file, no root and no container.
Workspace sync over the wire is deliberately not here: Run carries a
hub-side cwd, honest for loopback-shaped deployments and this test
tier, and the module says so rather than pretending.
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/src/config.rs b/src/config.rs index e544b2d..864540c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -43,6 +43,17 @@ pub struct Config { pub gpg_bin: String, /// Unprivileged user that runs PKGBUILD code (§14). Empty = current user. pub build_user: String, + /// Where build code runs: `loopback` (subprocesses of this process — + /// tests and the single-machine deployment) or `remote` (sandboxes that + /// dial in via the agent protocol). See `crate::sandbox`. + pub sandbox_backend: String, + /// Address the hub listens on for sandbox agents when + /// `sandbox_backend = "remote"`. Port 0 is allowed and resolves at bind. + pub agent_listen: String, + /// Shared secret an agent must present at rendezvous. A sandbox is + /// untrusted the moment it boots; this token is the only thing telling + /// the hub "you belong to me" — deploy it like one. + pub agent_token: String, /// Test-only hooks (§16a). Not part of the production configuration at all /// unless the crate is built with `test-support` — see [`TestHooks`]. #[cfg(feature = "test-support")] @@ -131,6 +142,9 @@ impl Default for Config { repo_add_bin: "repo-add".into(), gpg_bin: "gpg".into(), build_user: String::new(), + sandbox_backend: "loopback".into(), + agent_listen: String::new(), + agent_token: String::new(), #[cfg(feature = "test-support")] hooks: TestHooks::default(), max_concurrent_builds: 1, @@ -177,9 +191,13 @@ impl Config { } /// Environment for a child process: PATH with the shims in front, plus the - /// shim protocol variables (§16a). + /// shim protocol variables (§16a). The pairs form is what the remote + /// backend puts on the wire, so a remote child sees exactly what a local + /// one would. #[cfg_attr(not(feature = "test-support"), allow(unused_variables))] - pub fn child_env(&self, cmd: &mut std::process::Command) { + pub fn child_env_pairs(&self) -> Vec<(String, String)> { + #[cfg_attr(not(feature = "test-support"), allow(unused_mut))] + let mut pairs = Vec::new(); // Without `test-support` there is no shim protocol to export and no // PATH to rewrite: the child inherits the real environment, which is // what a real build needs (§16a). @@ -188,24 +206,34 @@ impl Config { let h = &self.hooks; if let Some(dir) = &h.path_prepend { let path = std::env::var("PATH").unwrap_or_default(); - cmd.env("PATH", format!("{}:{path}", dir.display())); + pairs.push(("PATH".to_string(), format!("{}:{path}", dir.display()))); } if let Some(m) = &h.shim_manifest { - cmd.env("AUR_SHIM_MANIFEST", m); + pairs.push(("AUR_SHIM_MANIFEST".to_string(), m.display().to_string())); } if let Some(d) = &h.shim_dir { - cmd.env("AUR_SHIM_DIR", d); + pairs.push(("AUR_SHIM_DIR".to_string(), d.display().to_string())); } if let Some(f) = &h.shim_fail { - cmd.env("AUR_SHIM_FAIL", f); + pairs.push(("AUR_SHIM_FAIL".to_string(), f.clone())); } if let Some(k) = &h.shim_kill_parent { - cmd.env("AUR_SHIM_KILL_PARENT", k); + pairs.push(("AUR_SHIM_KILL_PARENT".to_string(), k.clone())); } if let Some(l) = &h.shim_plant_link { - cmd.env("AUR_SHIM_PLANT_LINK", l); + pairs.push(("AUR_SHIM_PLANT_LINK".to_string(), l.clone())); } } + pairs + } + + /// Environment for a child process: PATH with the shims in front, plus the + /// shim protocol variables (§16a). + #[cfg_attr(not(feature = "test-support"), allow(unused_variables))] + pub fn child_env(&self, cmd: &mut std::process::Command) { + for (k, v) in self.child_env_pairs() { + cmd.env(k, v); + } } /// Create the directory tree the server needs. Idempotent. |
