Share helper reconciliation and verify Linux and Windows native fixtures
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-14 01:14:11 +01:00
parent 31278bedec
commit a6c1f9accc
14 changed files with 2557 additions and 1293 deletions
+16
View File
@@ -138,3 +138,19 @@ impl Outcome {
}
}
}
/// Explicit configured privileged identity; never infer SYSTEM from Linux root.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum HelperIdentity {
#[default]
Root,
System,
}
impl HelperIdentity {
pub fn as_str(self) -> &'static str {
match self {
Self::Root => "root",
Self::System => "system",
}
}
}
+16
View File
@@ -3,6 +3,7 @@ use anyhow::Result;
use ed25519_dalek::{Signature, VerifyingKey};
pub trait Ed25519Verifier {
fn validate_key(&self, public_key: &[u8]) -> Result<bool>;
fn verify(&self, public_key: &[u8], message: &[u8], signature: &[u8]) -> Result<bool>;
}
@@ -10,6 +11,13 @@ pub trait Ed25519Verifier {
pub struct DalekVerifier;
impl Ed25519Verifier for DalekVerifier {
fn validate_key(&self, public_key: &[u8]) -> Result<bool> {
let Ok(raw): Result<&[u8; 32], _> = public_key.try_into() else {
return Ok(false);
};
Ok(VerifyingKey::from_bytes(raw).is_ok_and(|key| !key.is_weak()))
}
fn verify(&self, public_key: &[u8], message: &[u8], signature: &[u8]) -> Result<bool> {
let Ok(raw): Result<&[u8; 32], _> = public_key.try_into() else {
return Ok(false);
@@ -33,6 +41,14 @@ pub struct OpenSslVerifier;
#[cfg(all(unix, feature = "openssl-verifier"))]
impl Ed25519Verifier for OpenSslVerifier {
fn validate_key(&self, public_key: &[u8]) -> Result<bool> {
if public_key.len() != 32 {
return Ok(false);
}
openssl::pkey::PKey::public_key_from_raw_bytes(public_key, openssl::pkey::Id::ED25519)?;
Ok(true)
}
fn verify(&self, public_key: &[u8], message: &[u8], signature: &[u8]) -> Result<bool> {
use openssl::{
pkey::{Id, PKey},
File diff suppressed because it is too large Load Diff
+1
View File
@@ -4,6 +4,7 @@
//! supply a qualified clock. A successful signature is never UI approval itself.
pub mod auth;
pub mod crypto;
pub mod helper_reconcile;
pub mod jobs;
pub mod ledger;
pub mod reconcile;
+21 -3
View File
@@ -3,6 +3,7 @@
//! Call only while holding the existing agent.lock. HelperSnapshot must come
//! from the independently authenticated root-helper IPC, never from the server.
use crate::auth::Binding;
pub use crate::auth::HelperIdentity;
use crate::crypto::{DefaultVerifier, Ed25519Verifier};
use anyhow::{Context, Result, ensure};
use chrono::{DateTime, Utc};
@@ -69,6 +70,7 @@ struct Gate {
pub struct ClientSync<V = DefaultVerifier> {
binding: Binding,
verifier: V,
helper_identity: HelperIdentity,
pending: Option<PreparedSync>,
channel: Option<Channel>,
gate: Option<Gate>,
@@ -84,11 +86,18 @@ impl<V: Ed25519Verifier> ClientSync<V> {
Self {
binding,
verifier,
helper_identity: HelperIdentity::Root,
pending: None,
channel: None,
gate: None,
}
}
/// Configure one explicit helper identity; changing it discards all leases.
pub fn with_helper_identity(mut self, identity: HelperIdentity) -> Self {
self.close();
self.helper_identity = identity;
self
}
/// Invoke on every authenticated/fenced ServerHello or transport loss.
pub fn close(&mut self) {
self.gate = None;
@@ -204,7 +213,15 @@ impl<V: Ed25519Verifier> ClientSync<V> {
ensure!(meta.helper_id.is_none(), "HELPER_JOURNAL_DISAPPEARED");
}
if let Some(h) = helper {
ingest_helper(&tx, ledger, &self.binding, &channel, h, now)?;
ingest_helper(
&tx,
ledger,
&self.binding,
&channel,
h,
now,
self.helper_identity,
)?;
}
archive_events(&tx)?;
tx.execute(
@@ -884,6 +901,7 @@ fn ingest_helper(
channel: &Channel,
helper: &HelperSnapshot,
now: DateTime<Utc>,
identity: HelperIdentity,
) -> Result<()> {
let mut statement = db.prepare("SELECT job,attempt,offer FROM job_attempts")?;
for row in statement.query_map([], |r| {
@@ -895,7 +913,7 @@ fn ingest_helper(
})? {
let (job, attempt, bytes) = row?;
let offer = JobOffer::decode(bytes.as_slice())?;
if binding.job(&offer.payload_bytes)?.execution_identity == "root" {
if binding.job(&offer.payload_bytes)?.execution_identity == identity.as_str() {
let consumed: bool = ledger.query_row(
"SELECT EXISTS(SELECT 1 FROM consumed WHERE job=?1 AND attempt=?2)",
params![job, attempt],
@@ -928,7 +946,7 @@ fn ingest_helper(
let offer = JobOffer::decode(bytes.as_slice())?;
let job = binding.job(&offer.payload_bytes)?;
ensure!(
job.execution_identity == "root"
job.execution_identity == identity.as_str()
&& h.job_payload_hash == offer.job_payload_hash
&& (grant.is_empty() || grant == h.grant_id),
"HELPER_ATTEMPT_BINDING"