From c67ecea7e22b890a3014a884585d801a2fcc3293 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 11 Dec 2018 12:09:21 +0100 Subject: Show error in pinentry dialog instead of printing to stdout Currently, the error message for a wrong password is printed to the standard output. Yet the standard output might not be visible to the user if they are using the curses frontend for pinentry. Pinentry already supports displaying an error message in the passphrase prompt. This patch moves the error message from the standard output to the pinentry prompt. --- nitrocli/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'nitrocli/src/main.rs') diff --git a/nitrocli/src/main.rs b/nitrocli/src/main.rs index 3ec3243..0ba232f 100644 --- a/nitrocli/src/main.rs +++ b/nitrocli/src/main.rs @@ -253,8 +253,9 @@ fn open() -> Result<()> { nitrokey_do(&|handle| { let mut retry = 3; + let mut error_msg: Option<&str> = None; loop { - let passphrase = pinentry::inquire_passphrase()?; + let passphrase = pinentry::inquire_passphrase(error_msg)?; let payload = nitrokey::EnableEncryptedVolumeCommand::new(&passphrase); let report = nitrokey::Report::from(payload); @@ -267,7 +268,7 @@ fn open() -> Result<()> { retry -= 1; if retry > 0 { - println!("Wrong password, please reenter"); + error_msg = Some("Wrong password, please reenter"); continue; } let error = "Opening encrypted volume failed: Wrong password"; -- cgit v1.2.1