aboutsummaryrefslogtreecommitdiff
path: root/ext/otp-cache/src/main.rs
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2020-09-19 22:31:20 -0700
committerDaniel Mueller <deso@posteo.net>2020-10-11 17:07:09 -0700
commitc7b64866c483036b548b336b8de2172d9da66ea9 (patch)
tree79f51086342d6f4ce1eb47da28744f9bfa1f7cb7 /ext/otp-cache/src/main.rs
parented59adcc9280d937f0f6f3627104597681ce7347 (diff)
downloadnitrocli-c7b64866c483036b548b336b8de2172d9da66ea9.tar.gz
nitrocli-c7b64866c483036b548b336b8de2172d9da66ea9.tar.bz2
Kill scdaemon before each OTP get
TODO: Should probably be done on other paths as well.
Diffstat (limited to 'ext/otp-cache/src/main.rs')
-rw-r--r--ext/otp-cache/src/main.rs11
1 files changed, 11 insertions, 0 deletions
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<Cache> {
}
fn generate_otp(ctx: &ext::Context, args: &Args, slot: u8) -> anyhow::Result<String> {
+ // 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())