diff options
| author | Andrew Guschin <guschin@altlinux.org> | 2026-10-30 04:43:59 +0400 |
|---|---|---|
| committer | Andrew Guschin <guschin@altlinux.org> | 2026-10-30 04:43:59 +0400 |
| commit | 7999fab25c5172207ee41e38732f4923565ff6b6 (patch) | |
| tree | 0e239d6ba65d4babfc0f1007ac350f6f4f9e73d1 /src/bus.rs | |
| parent | fc3c1d51b1be9db6ba6ad286584fbc34bb305f38 (diff) | |
Validate controller diagnostics, reboot protection, and terminal authentication
Diffstat (limited to 'src/bus.rs')
| -rw-r--r-- | src/bus.rs | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -308,13 +308,22 @@ impl Client { ) -> Result<String> { let proxy = self.proxy().await?; let arguments = (id.unwrap_or(""), speed, interactive); - tokio::select! { - result = proxy.call("Diagnostic", &arguments) => Ok(result?), + let value: String = tokio::select! { + result = proxy.call("Diagnostic", &arguments) => result?, _ = tokio::signal::ctrl_c() => { let _: () = proxy.call("CancelDiagnostic", &(interactive,)).await?; anyhow::bail!("Diagnostic cancelled; proxy intent is unchanged") } + }; + let observation: crate::diagnostics::Observation = serde_json::from_str(&value)?; + if !observation.success { + let delay = observation + .retry_after_seconds + .map(|seconds| format!("; retry after at least {seconds} seconds")) + .unwrap_or_default(); + anyhow::bail!("Diagnostic failed: {}{}", observation.stop_reason, delay); } + Ok(value) } pub async fn change(&self, operation: Operation, interactive: bool) -> Result<()> { let proxy = self.proxy().await?; |