feat: v1.7.3, supports pinentry
This commit is contained in:
16
src/util.rs
16
src/util.rs
@@ -28,8 +28,8 @@ impl AsRef<[u8]> for SecVec {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_pin(pin: &Option<String>) -> String {
|
||||
match pin {
|
||||
pub fn read_pin(pin: &Option<String>) -> XResult<String> {
|
||||
let rpin = match pin {
|
||||
Some(pin) => pin.to_string(),
|
||||
None => if !util_env::get_no_default_pin_hint() && util_term::read_yes_no("Use default PIN 123456, please confirm") {
|
||||
"123456".into()
|
||||
@@ -37,18 +37,18 @@ pub fn read_pin(pin: &Option<String>) -> String {
|
||||
let pin_entry = util_env::get_pin_entry().unwrap_or_else(|| "pinentry".to_string());
|
||||
if let Some(mut input) = PassphraseInput::with_binary(pin_entry) {
|
||||
let secret = input
|
||||
.with_description("Enter new passphrase for FooBar")
|
||||
.with_prompt("Passphrase:")
|
||||
.with_confirmation("Confirm passphrase:", "Passphrases do not match")
|
||||
.with_description("Please input your PIN.")
|
||||
.with_prompt("PIN:")
|
||||
.interact();
|
||||
secret.expect("Read PIN from pinentry failed")
|
||||
opt_result!(secret, "Read PIN from pinentry failed: {}")
|
||||
.expose_secret()
|
||||
.to_string()
|
||||
} else {
|
||||
rpassword::prompt_password("Please input PIN: ").expect("Read PIN failed")
|
||||
opt_result!(rpassword::prompt_password("Please input PIN: "), "Read PIN failed: {}")
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Ok(rpin)
|
||||
}
|
||||
|
||||
pub fn remove_file_with_msg(path: &PathBuf) {
|
||||
|
||||
Reference in New Issue
Block a user