feat: v1.9.9

This commit is contained in:
2025-08-24 13:53:33 +08:00
parent b94acf9c31
commit 6a24388a19
3 changed files with 21 additions and 18 deletions

View File

@@ -40,23 +40,26 @@ pub fn read_stdin() -> XResult<Vec<u8>> {
}
pub fn read_pin(pin: &Option<String>) -> XResult<String> {
let rpin = match pin {
Some(pin) => pin.to_string(),
None => if is_use_default_pin() {
"123456".into()
if let Some(pin) = pin {
if pin != "#INPUT#" {
return Ok(pin.to_string());
}
}
if is_use_default_pin() {
return Ok("123456".into());
}
let rpin = {
let pin_entry = util_env::get_default_pin_entry().unwrap_or_else(|| "pinentry".to_string());
if let Some(mut input) = PassphraseInput::with_binary(pin_entry) {
let secret = input
.with_description("Please input your PIN.")
.with_prompt("PIN:")
.interact();
opt_result!(secret, "Read PIN from pinentry failed: {}")
.expose_secret()
.to_string()
} else {
let pin_entry = util_env::get_default_pin_entry().unwrap_or_else(|| "pinentry".to_string());
if let Some(mut input) = PassphraseInput::with_binary(pin_entry) {
let secret = input
.with_description("Please input your PIN.")
.with_prompt("PIN:")
.interact();
opt_result!(secret, "Read PIN from pinentry failed: {}")
.expose_secret()
.to_string()
} else {
opt_result!(rpassword::prompt_password("Please input PIN: "), "Read PIN failed: {}")
}
opt_result!(rpassword::prompt_password("Please input PIN: "), "Read PIN failed: {}")
}
};
Ok(rpin)