Ask for the password even if stdin is not connected to the TTY.
- As we prompt on the TTY, we can do that even if stdin is not
connected to it.
- Reverts f3cfb1b602
.
- Fixes #167.
This commit is contained in:
parent
1b4761a045
commit
fc3e4e046e
41
src/sq.rs
41
src/sq.rs
@ -7,7 +7,6 @@
|
||||
#![doc = include_str!(concat!(env!("OUT_DIR"), "/sq-usage.md"))]
|
||||
|
||||
use anyhow::Context as _;
|
||||
use is_terminal::IsTerminal;
|
||||
|
||||
use std::borrow::Borrow;
|
||||
use std::cell::OnceCell;
|
||||
@ -271,28 +270,26 @@ fn decrypt_key<R>(key: Key<key::SecretParts, R>, passwords: &mut Vec<Password>)
|
||||
}
|
||||
}
|
||||
|
||||
if std::io::stdin().is_terminal() {
|
||||
loop {
|
||||
// Prompt the user.
|
||||
match common::password::prompt_to_unlock_or_cancel(&format!(
|
||||
"{} (blank to skip)", key.keyid().to_hex()
|
||||
)) {
|
||||
Ok(None) => break, // Give up.
|
||||
Ok(Some(p)) => {
|
||||
if let Ok(key) = key
|
||||
.clone()
|
||||
.decrypt_secret(&p)
|
||||
{
|
||||
passwords.push(p.into());
|
||||
return Ok(key);
|
||||
}
|
||||
loop {
|
||||
// Prompt the user.
|
||||
match common::password::prompt_to_unlock_or_cancel(&format!(
|
||||
"{} (blank to skip)", key.keyid().to_hex()
|
||||
)) {
|
||||
Ok(None) => break, // Give up.
|
||||
Ok(Some(p)) => {
|
||||
if let Ok(key) = key
|
||||
.clone()
|
||||
.decrypt_secret(&p)
|
||||
{
|
||||
passwords.push(p.into());
|
||||
return Ok(key);
|
||||
}
|
||||
|
||||
wprintln!("Incorrect password.");
|
||||
}
|
||||
Err(err) => {
|
||||
wprintln!("While reading password: {}", err);
|
||||
break;
|
||||
}
|
||||
wprintln!("Incorrect password.");
|
||||
}
|
||||
Err(err) => {
|
||||
wprintln!("While reading password: {}", err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user