@@ -1,6 +1,7 @@ |
| 1 | use crate::agent::{ | 1 | use crate::agent::{ |
| 2 | AuthAgentBackend, PolkitAgent, PolkitBackendConfig, StubPolkitAgent, | 2 | AuthAgentBackend, PolkitAgent, PolkitBackendConfig, StubPolkitAgent, |
| 3 | - enumerate_temporary_authorizations, | 3 | + enumerate_temporary_authorizations, revoke_all_temporary_authorizations, |
| | 4 | + revoke_temporary_authorization_by_id, |
| 4 | }; | 5 | }; |
| 5 | use crate::config::{AgentBackendMode, Config}; | 6 | use crate::config::{AgentBackendMode, Config}; |
| 6 | use crate::state::{AuthState, RuntimeState}; | 7 | use crate::state::{AuthState, RuntimeState}; |
@@ -298,6 +299,25 @@ fn dispatch( |
| 298 | err | 299 | err |
| 299 | )), | 300 | )), |
| 300 | }, | 301 | }, |
| | 302 | + Command::TempRevoke { authorization_id } => { |
| | 303 | + match revoke_temporary_authorization_by_id(authorization_id.as_str()) { |
| | 304 | + Ok(()) => Response::ok_with_data(json!({ |
| | 305 | + "authorization_id": authorization_id, |
| | 306 | + "revoked": true |
| | 307 | + })), |
| | 308 | + Err(err) => Response::err(format!( |
| | 309 | + "failed to revoke temporary authorization {}: {}", |
| | 310 | + authorization_id, err |
| | 311 | + )), |
| | 312 | + } |
| | 313 | + } |
| | 314 | + Command::TempRevokeAll => match revoke_all_temporary_authorizations() { |
| | 315 | + Ok(revoked_count) => Response::ok_with_data(json!({ "revoked_count": revoked_count })), |
| | 316 | + Err(err) => Response::err(format!( |
| | 317 | + "failed to revoke temporary authorizations: {}", |
| | 318 | + err |
| | 319 | + )), |
| | 320 | + }, |
| 301 | Command::Quit => { | 321 | Command::Quit => { |
| 302 | if shutdown_tx.send(()).is_err() { | 322 | if shutdown_tx.send(()).is_err() { |
| 303 | Response::err("daemon shutdown channel unavailable") | 323 | Response::err("daemon shutdown channel unavailable") |