summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2018-12-23 01:39:59 +0100
committerDaniel Mueller <deso@posteo.net>2018-12-24 17:51:03 -0800
commite0a7aa80c5c2b049538d9d333e9ce919a4a56dce (patch)
tree4ee17995407be4232bc2fd6002f818386d8e5efd
parent27ed7f31128cf17dee1ab8e7cfa49f45ca123aec (diff)
downloadnitrocli-e0a7aa80c5c2b049538d9d333e9ce919a4a56dce.tar.gz
nitrocli-e0a7aa80c5c2b049538d9d333e9ce919a4a56dce.tar.bz2
Clear both user and admin PIN
Currently, we only clear the user PIN if clear is called. This patch changes the clear command to also clear the admin PIN as we will start to use the admin PIN in upcoming patches.
-rw-r--r--nitrocli/src/args.rs2
-rw-r--r--nitrocli/src/commands.rs6
-rw-r--r--nitrocli/src/pinentry.rs1
3 files changed, 4 insertions, 5 deletions
diff --git a/nitrocli/src/args.rs b/nitrocli/src/args.rs
index 07a3e6a..d4c3809 100644
--- a/nitrocli/src/args.rs
+++ b/nitrocli/src/args.rs
@@ -115,7 +115,7 @@ fn close(args: Vec<String>) -> Result<()> {
/// Clear the PIN stored when opening the nitrokey's encrypted volume.
fn clear(args: Vec<String>) -> Result<()> {
let mut parser = argparse::ArgumentParser::new();
- parser.set_description("Clears the cached passphrase");
+ parser.set_description("Clears the cached passphrases");
parse(&parser, args)?;
commands::clear()
diff --git a/nitrocli/src/commands.rs b/nitrocli/src/commands.rs
index 269cafc..b3e71a1 100644
--- a/nitrocli/src/commands.rs
+++ b/nitrocli/src/commands.rs
@@ -23,8 +23,6 @@ use crate::error::Error;
use crate::pinentry;
use crate::Result;
-const PIN_TYPE: pinentry::PinType = pinentry::PinType::User;
-
/// Create an `error::Error` with an error message of the format `msg: err`.
fn get_error(msg: &str, err: &nitrokey::CommandError) -> Error {
Error::Error(format!("{}: {:?}", msg, err))
@@ -198,5 +196,7 @@ pub fn close() -> Result<()> {
/// Clear the PIN stored when opening the nitrokey's encrypted volume.
pub fn clear() -> Result<()> {
- pinentry::clear_passphrase(PIN_TYPE)
+ pinentry::clear_passphrase(pinentry::PinType::Admin)?;
+ pinentry::clear_passphrase(pinentry::PinType::User)?;
+ Ok(())
}
diff --git a/nitrocli/src/pinentry.rs b/nitrocli/src/pinentry.rs
index ce9a98f..891de38 100644
--- a/nitrocli/src/pinentry.rs
+++ b/nitrocli/src/pinentry.rs
@@ -28,7 +28,6 @@ use crate::error::Error;
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum PinType {
/// The admin PIN.
- #[allow(unused)]
Admin,
/// The user PIN.
User,