-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TTY detection and handling #2
Comments
- Prevent passphrase from being echoed. - Confirm passphrase entry when encrypting. - Require that input files are passed as CLI arguments so they don't conflict with passphrase input. Part of #2.
age currently opens |
Oh, turns out that the |
Hmm, turns out it isn't that simple. The expected diff would be: diff --git a/src/bin/rage/error.rs b/src/bin/rage/error.rs
index c9d8dca..bf5b758 100644
--- a/src/bin/rage/error.rs
+++ b/src/bin/rage/error.rs
@@ -48,6 +48,7 @@ pub(crate) enum DecryptError {
Io(io::Error),
MissingIdentities(String),
MixedIdentityAndPassphrase,
+ #[cfg(not(unix))]
PassphraseWithoutFileArgument,
RecipientFlag,
UnsupportedKey(String, age::keys::UnsupportedKey),
@@ -89,6 +90,7 @@ impl fmt::Display for DecryptError {
DecryptError::MixedIdentityAndPassphrase => {
write!(f, "-i/--identity can't be used with -p/--passphrase")
}
+ #[cfg(not(unix))]
DecryptError::PassphraseWithoutFileArgument => write!(
f,
"File to decrypt must be passed as an argument when using -p/--passphrase"
diff --git a/src/bin/rage/main.rs b/src/bin/rage/main.rs
index 130f9d6..164b097 100644
--- a/src/bin/rage/main.rs
+++ b/src/bin/rage/main.rs
@@ -267,8 +267,13 @@ fn decrypt(opts: AgeOptions) -> Result<(), error::DecryptError> {
return Err(error::DecryptError::MixedIdentityAndPassphrase);
}
- if opts.input.is_none() {
- return Err(error::DecryptError::PassphraseWithoutFileArgument);
+ // The `console` crate used by `dialoguer::PasswordInput` opens `/dev/tty`
+ // directly on Unix, so we don't have any conflict with stdin.
+ #[cfg(not(unix))]
+ {
+ if opts.input.is_none() {
+ return Err(error::DecryptError::PassphraseWithoutFileArgument);
+ }
}
match read_secret("Type passphrase", None) { But with this, running |
Turns out this is caused by a problem somewhere in the |
--passphrase / -p
flag.The text was updated successfully, but these errors were encountered: