feat: support pin entry file cmd
This commit is contained in:
@@ -17,7 +17,9 @@ use std::{env, fs};
|
|||||||
use pinentry::PassphraseInput;
|
use pinentry::PassphraseInput;
|
||||||
use secrecy::ExposeSecret;
|
use secrecy::ExposeSecret;
|
||||||
|
|
||||||
|
const HOME_ENV: &str = "HOME";
|
||||||
const PIN_ENTRY_ENV: &str = "PIN_ENTRY_CMD";
|
const PIN_ENTRY_ENV: &str = "PIN_ENTRY_CMD";
|
||||||
|
const PIN_ENTRY_CMD_FILE: &str = ".pinentry.cmd";
|
||||||
const PIN_ENTRY_1: &str = "/usr/local/MacGPG2/libexec/pinentry-mac.app/Contents/MacOS/pinentry-mac";
|
const PIN_ENTRY_1: &str = "/usr/local/MacGPG2/libexec/pinentry-mac.app/Contents/MacOS/pinentry-mac";
|
||||||
const PIN_ENTRY_DEFAULT: &str = "pinentry";
|
const PIN_ENTRY_DEFAULT: &str = "pinentry";
|
||||||
|
|
||||||
@@ -56,6 +58,11 @@ fn get_pin_entry() -> String {
|
|||||||
if let Ok(pin_entry) = env::var(PIN_ENTRY_ENV) {
|
if let Ok(pin_entry) = env::var(PIN_ENTRY_ENV) {
|
||||||
return pin_entry;
|
return pin_entry;
|
||||||
}
|
}
|
||||||
|
if let Ok(home) = env::var(HOME_ENV) {
|
||||||
|
if let Ok(pin_entry_cmd) = fs::read_to_string(format!("{}/{}", home, PIN_ENTRY_CMD_FILE)) {
|
||||||
|
return pin_entry_cmd.trim().to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Ok(m) = fs::metadata(PIN_ENTRY_1) {
|
if let Ok(m) = fs::metadata(PIN_ENTRY_1) {
|
||||||
if m.is_file() {
|
if m.is_file() {
|
||||||
return PIN_ENTRY_1.to_string();
|
return PIN_ENTRY_1.to_string();
|
||||||
|
|||||||
Reference in New Issue
Block a user