Fix the password prompts.

- Fixes a5a7fd09b6.
This commit is contained in:
Justus Winter 2024-01-08 10:49:00 +01:00
parent fd08784e3a
commit 86058193e1
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386
2 changed files with 4 additions and 3 deletions

View File

@ -52,7 +52,8 @@ pub fn prompt_for_new(
/// if a key or subkey is locked and must be unlocked, or a message
/// should be decrypted using a password.
pub fn prompt_to_unlock(reason: &str) -> Result<Password> {
let prompt = format!("Please enter the password to decrypt the {}", reason);
let prompt =
format!("Please enter the password to decrypt the {}: ", reason);
let password = prompt_password(&prompt)?;
Ok(password.into())
}
@ -63,6 +64,6 @@ pub fn prompt_to_unlock(reason: &str) -> Result<Password> {
/// if a key or subkey is locked and must be unlocked, or a message
/// should be decrypted using a password.
pub fn prompt_to_unlock_or_cancel(reason: &str) -> Result<Option<Password>> {
let password = prompt_to_unlock(reason)?;
let password = prompt_to_unlock(&format!("{} (blank to skip)", reason))?;
Ok(if password.map(|p| p.is_empty()) { None } else { Some(password) })
}

View File

@ -273,7 +273,7 @@ fn decrypt_key<R>(key: Key<key::SecretParts, R>, passwords: &mut Vec<Password>)
loop {
// Prompt the user.
match common::password::prompt_to_unlock_or_cancel(&format!(
"{} (blank to skip)", key.keyid().to_hex()
"key {}", key.keyid(),
)) {
Ok(None) => break, // Give up.
Ok(Some(p)) => {