From c7b64866c483036b548b336b8de2172d9da66ea9 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Sat, 19 Sep 2020 22:31:20 -0700 Subject: Kill scdaemon before each OTP get TODO: Should probably be done on other paths as well. --- ext/otp-cache/src/main.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ext') diff --git a/ext/otp-cache/src/main.rs b/ext/otp-cache/src/main.rs index b554b6e..c39fa2d 100644 --- a/ext/otp-cache/src/main.rs +++ b/ext/otp-cache/src/main.rs @@ -9,6 +9,7 @@ use std::collections; use std::fs; use std::io::Write as _; use std::path; +use std::process; use anyhow::Context as _; @@ -153,6 +154,16 @@ fn load_cache(path: &path::Path) -> anyhow::Result { } fn generate_otp(ctx: &ext::Context, args: &Args, slot: u8) -> anyhow::Result { + // Attempt to prevent a "hang" of the Nitrokey by killing any scdaemon + // that could currently have the device opened itself + // (https://github.com/Nitrokey/libnitrokey/issues/137). + let _ = process::Command::new("gpg-connect-agent") + .stdout(process::Stdio::null()) + .stderr(process::Stdio::null()) + .arg("SCD KILLSCD") + .arg("/bye") + .output(); + ext::Nitrocli::from_context(ctx) .args(&["otp", "get"]) .arg(slot.to_string()) -- cgit v1.2.3