aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-03-02 22:13:21 -0500
committerJesse Luehrs <doy@tozt.net>2021-03-02 22:13:21 -0500
commit604e09e6ae098350bffe18bde26e1c62f7e88a00 (patch)
treeed40c95a683fa200b11dc3f19accca7eee48ccd5
parentd149a01bffd2bfdd16e471c8be55f7760c70dd69 (diff)
downloadrbw-604e09e6ae098350bffe18bde26e1c62f7e88a00.tar.gz
rbw-604e09e6ae098350bffe18bde26e1c62f7e88a00.zip
make the pinentry program configurable
-rw-r--r--CHANGELOG.md4
-rw-r--r--README.md3
-rw-r--r--src/bin/rbw-agent/actions.rs8
-rw-r--r--src/bin/rbw/commands.rs2
-rw-r--r--src/config.rs7
-rw-r--r--src/pinentry.rs3
6 files changed, 26 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 664b165..08b6bed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
## [Unreleased]
+### Added
+* You can now `rbw config set pinentry pinentry-curses` to change the pinentry
+ program used by `rbw` (#39, djmattyg007)
+
### Changed
* On Linux, the `rbw-agent` process can no longer be attached to by debuggers,
diff --git a/README.md b/README.md
index 0df94bc..8e30f7f 100644
--- a/README.md
+++ b/README.md
@@ -59,6 +59,9 @@ configuration options:
* `lock_timeout`: The number of seconds to keep the master keys in memory for
before requiring the password to be entered again. Defaults to `3600` (one
hour).
+* `pinentry`: The
+ [pinentry](https://www.gnupg.org/related_software/pinentry/index.html)
+ executable to use. Defaults to `pinentry`.
## Usage
diff --git a/src/bin/rbw-agent/actions.rs b/src/bin/rbw-agent/actions.rs
index 1a5a3c5..4f4096e 100644
--- a/src/bin/rbw-agent/actions.rs
+++ b/src/bin/rbw-agent/actions.rs
@@ -32,6 +32,7 @@ pub async fn login(
None
};
let password = rbw::pinentry::getpin(
+ &config_pinentry().await?,
"Master Password",
&format!("Log in to {}", host),
err.as_deref(),
@@ -134,6 +135,7 @@ async fn two_factor(
None
};
let code = rbw::pinentry::getpin(
+ &config_pinentry().await?,
"Authenticator App",
"Enter the 6 digit verification code from your authenticator app.",
err.as_deref(),
@@ -293,6 +295,7 @@ pub async fn unlock(
None
};
let password = rbw::pinentry::getpin(
+ &config_pinentry().await?,
"Master Password",
"Unlock the local database",
err.as_deref(),
@@ -532,3 +535,8 @@ async fn config_base_url() -> anyhow::Result<String> {
let config = rbw::config::Config::load_async().await?;
Ok(config.base_url())
}
+
+async fn config_pinentry() -> anyhow::Result<String> {
+ let config = rbw::config::Config::load_async().await?;
+ Ok(config.pinentry)
+}
diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs
index 3f11174..2da06a2 100644
--- a/src/bin/rbw/commands.rs
+++ b/src/bin/rbw/commands.rs
@@ -425,6 +425,7 @@ pub fn config_set(key: &str, value: &str) -> anyhow::Result<()> {
config.lock_timeout = timeout;
}
}
+ "pinentry" => config.pinentry = value.to_string(),
_ => return Err(anyhow::anyhow!("invalid config key: {}", key)),
}
config.save()?;
@@ -449,6 +450,7 @@ pub fn config_unset(key: &str) -> anyhow::Result<()> {
"lock_timeout" => {
config.lock_timeout = rbw::config::default_lock_timeout()
}
+ "pinentry" => config.pinentry = rbw::config::default_pinentry(),
_ => return Err(anyhow::anyhow!("invalid config key: {}", key)),
}
config.save()?;
diff --git a/src/config.rs b/src/config.rs
index 418da45..9bb4696 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -10,6 +10,8 @@ pub struct Config {
pub identity_url: Option<String>,
#[serde(default = "default_lock_timeout")]
pub lock_timeout: u64,
+ #[serde(default = "default_pinentry")]
+ pub pinentry: String,
}
impl Default for Config {
@@ -19,6 +21,7 @@ impl Default for Config {
base_url: Default::default(),
identity_url: Default::default(),
lock_timeout: default_lock_timeout(),
+ pinentry: default_pinentry(),
}
}
}
@@ -27,6 +30,10 @@ pub fn default_lock_timeout() -> u64 {
3600
}
+pub fn default_pinentry() -> String {
+ "pinentry".to_string()
+}
+
impl Config {
pub fn new() -> Self {
Self::default()
diff --git a/src/pinentry.rs b/src/pinentry.rs
index 69bf92c..9711585 100644
--- a/src/pinentry.rs
+++ b/src/pinentry.rs
@@ -3,12 +3,13 @@ use crate::prelude::*;
use tokio::io::AsyncWriteExt as _;
pub async fn getpin(
+ pinentry: &str,
prompt: &str,
desc: &str,
err: Option<&str>,
tty: Option<&str>,
) -> Result<crate::locked::Password> {
- let mut opts = tokio::process::Command::new("pinentry");
+ let mut opts = tokio::process::Command::new(pinentry);
opts.stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped());
if let Some(tty) = tty {