From 1af3a4b5ee96b9082116d9900dae685a7045141b Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Tue, 3 Aug 2021 23:18:19 +0200 Subject: [PATCH] Explore shutting down scdaemon when accessing cards via pcsc. --- card-functionality/Cargo.toml | 3 ++- card-functionality/src/main.rs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/card-functionality/Cargo.toml b/card-functionality/Cargo.toml index 3cca554..368d0dd 100644 --- a/card-functionality/Cargo.toml +++ b/card-functionality/Cargo.toml @@ -15,4 +15,5 @@ openpgp-card-scdc = { path = "../scdc" } sequoia-openpgp = "1.3" anyhow = "1" thiserror = "1.0" -env_logger = "0.8" \ No newline at end of file +env_logger = "0.8" +log = "0.4" \ No newline at end of file diff --git a/card-functionality/src/main.rs b/card-functionality/src/main.rs index 25d4126..40967d3 100644 --- a/card-functionality/src/main.rs +++ b/card-functionality/src/main.rs @@ -49,6 +49,11 @@ impl TestCard { fn open(&self) -> Result { match self { Self::Pcsc(ident) => { + // Attempt to shutdown SCD, if it is running. + // Ignore any errors that occur during that shutdown attempt. + let res = ScdClient::shutdown_scd(None); + log::trace!(" Attempt to shutdown scd: {:?}", res); + for card in PcscClient::list_cards()? { let card_client = Box::new(card) as CardClientBox; let mut ca = CardApp::new(card_client);