diff options
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. |
