summaryrefslogtreecommitdiffstats
path: root/src/pipeline/publish.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/pipeline/publish.rs')
-rw-r--r--src/pipeline/publish.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/pipeline/publish.rs b/src/pipeline/publish.rs
index 94fc46f..fd2fdd1 100644
--- a/src/pipeline/publish.rs
+++ b/src/pipeline/publish.rs
@@ -308,10 +308,22 @@ fn sign(cfg: &Config, path: &Path) -> Result<()> {
if cfg.signing_key_id.is_empty() {
return Ok(());
}
+ let sig = format!("{}.sig", path.display());
+ sign_to(cfg, path, Path::new(&sig))
+}
+
+/// `gpg --detach-sign` over `path`, written to `sig_out` atomically. Shared by
+/// publish (the database) and ingest (the packages): one key, one code path,
+/// and the key never leaves the hub — a build sandbox signs nothing (§8,
+/// remote-builder design).
+pub(crate) fn sign_to(cfg: &Config, path: &Path, sig_out: &Path) -> Result<()> {
+ if cfg.signing_key_id.is_empty() {
+ return Ok(());
+ }
let mut cmd = Command::new(&cfg.gpg_bin);
cmd.args(["--batch", "--yes", "--detach-sign", "--local-user", &cfg.signing_key_id]);
cmd.arg("-o");
- let tmp = format!("{}.tmp", path.display());
+ let tmp = format!("{}.tmp", sig_out.display());
cmd.arg(&tmp);
cmd.arg(path);
cfg.child_env(&mut cmd);
@@ -322,7 +334,7 @@ fn sign(cfg: &Config, path: &Path) -> Result<()> {
detail: String::from_utf8_lossy(&out.stderr).into_owned(),
});
}
- std::fs::rename(&tmp, format!("{}.sig", path.display()))?;
+ std::fs::rename(&tmp, sig_out)?;
Ok(())
}