From 32c22bd1eb9fe05db30cf1062d089b21bd00c3a7 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 27 Dec 2018 17:57:26 +0100 Subject: Implement the lock command This patch implements the lock command that locks the password safe and, on the Nitrokey Storage, the encrypted volume. See issue #18 for details on the locking mechanism. --- nitrocli/src/args.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'nitrocli/src/args.rs') diff --git a/nitrocli/src/args.rs b/nitrocli/src/args.rs index 4cf6258..f1db33f 100644 --- a/nitrocli/src/args.rs +++ b/nitrocli/src/args.rs @@ -32,6 +32,7 @@ type Result = result::Result; #[derive(Debug)] pub enum Command { Config, + Lock, Otp, Pin, Pws, @@ -44,6 +45,7 @@ impl Command { pub fn execute(&self, args: Vec) -> Result<()> { match *self { Command::Config => config(args), + Command::Lock => lock(args), Command::Otp => otp(args), Command::Pin => pin(args), Command::Pws => pws(args), @@ -60,6 +62,7 @@ impl fmt::Display for Command { "{}", match *self { Command::Config => "config", + Command::Lock => "lock", Command::Otp => "otp", Command::Pin => "pin", Command::Pws => "pws", @@ -76,6 +79,7 @@ impl str::FromStr for Command { fn from_str(s: &str) -> result::Result { match s { "config" => Ok(Command::Config), + "lock" => Ok(Command::Lock), "otp" => Ok(Command::Otp), "pin" => Ok(Command::Pin), "pws" => Ok(Command::Pws), @@ -585,6 +589,15 @@ fn config_set(args: Vec) -> Result<()> { commands::config_set(numlock, capslock, scrollock, otp_pin) } +/// Lock the Nitrokey. +fn lock(args: Vec) -> Result<()> { + let mut parser = argparse::ArgumentParser::new(); + parser.set_description("Locks the connected Nitrokey device"); + parse(&parser, args)?; + + commands::lock() +} + /// Execute an OTP subcommand. fn otp(args: Vec) -> Result<()> { let mut subcommand = OtpCommand::Get; -- cgit v1.2.1