Integrate independent signed Windows clocks with native Linux lease guards
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-15 10:26:24 +01:00
parent 6ddfc95fff
commit 09f7e5af84
13 changed files with 1093 additions and 37 deletions
@@ -242,6 +242,81 @@ impl Client {
async fn call(&self, operation: ipc::Operation) -> Result<ipc::Reply> {
self.call_bounded(operation, Duration::from_secs(5)).await
}
async fn time_call(&self, operation: ipc::Operation, timeout: Duration) -> Result<ipc::Reply> {
// Separate from the long Execute lane, retained process-wide even if a
// caller/session is dropped while a blocking native call is outstanding.
static TIME_LANE: std::sync::OnceLock<Arc<Semaphore>> = std::sync::OnceLock::new();
let permit = TIME_LANE
.get_or_init(|| Arc::new(Semaphore::new(1)))
.clone()
.try_acquire_owned()
.context("HELPER_TIME_BUSY")?;
let client = self.clone();
tokio::task::spawn_blocking(move || {
let _permit = permit;
client.check_pin()?;
let call = ipc::Call::new(&client.pin, operation);
let reply = ipc::exchange_time(&client.pin, &call, timeout)?;
client.check_pin()?;
Ok(reply)
})
.await?
}
pub async fn time_begin(&self, generation: u64) -> Result<rmm_time_attestation::Request> {
let reply = self
.time_call(
ipc::Operation::TimeBegin { generation },
Duration::from_secs(20),
)
.await?;
let ipc::ReplyBody::TimeChallenge { request } = reply.body else {
anyhow::bail!("HELPER_TIME_BEGIN_DENIED");
};
request.validate()?;
ensure!(
request.context.role == rmm_time_attestation::Role::SystemHelper
&& request.context.connection_generation == generation
&& request.context.tenant_id == self.pin.binding.tenant_id
&& request.context.asset_id == self.pin.binding.asset_id
&& request.context.agent_id == self.pin.binding.agent_id
&& request.context.enrollment_generation == self.pin.binding.enrollment_generation
&& request.context.assignment_generation == self.pin.binding.assignment_version
&& request.context.helper_image_sha256.as_deref()
== Some(self.pin.helper.binary_sha256.as_str()),
"HELPER_TIME_REQUEST_BINDING"
);
Ok(request)
}
pub async fn time_complete(&self, generation: u64, response_bytes: Vec<u8>) -> Result<()> {
ensure!(response_bytes.len() <= 16384, "HELPER_TIME_RESPONSE_BOUND");
let reply = self
.time_call(
ipc::Operation::TimeComplete {
generation,
response_bytes,
},
Duration::from_secs(1),
)
.await?;
ensure!(
matches!(reply.body, ipc::ReplyBody::TimeCompleted {}),
"HELPER_TIME_COMPLETE_DENIED"
);
Ok(())
}
pub async fn time_close(&self, generation: u64) -> Result<()> {
let reply = self
.time_call(
ipc::Operation::TimeClose { generation },
Duration::from_secs(1),
)
.await?;
ensure!(
matches!(reply.body, ipc::ReplyBody::TimeClosed {}),
"HELPER_TIME_CLOSE_UNCONFIRMED"
);
Ok(())
}
async fn call_bounded(
&self,
operation: ipc::Operation,