summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2014-03-06 20:04:46 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2014-03-06 20:04:46 +0000
commit6a071b93061c9d69b90bf11df4d15a065d412257 (patch)
tree15547d4dd3b91c6b621b1dfd0ae60b554f2a62c8 /usr.bin
parent909a5f2a23b1641e9b8e1ed6f17f1624a17c3839 (diff)
allow password on stdin if it's not a tty. commonly requested.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/signify/signify.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/signify/signify.c b/usr.bin/signify/signify.c
index 229aea4de03..ddebdfcefde 100644
--- a/usr.bin/signify/signify.c
+++ b/usr.bin/signify/signify.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: signify.c,v 1.47 2014/03/06 15:01:58 naddy Exp $ */
+/* $OpenBSD: signify.c,v 1.48 2014/03/06 20:04:45 tedu Exp $ */
/*
* Copyright (c) 2013 Ted Unangst <tedu@openbsd.org>
*
@@ -252,13 +252,16 @@ static void
kdf(uint8_t *salt, size_t saltlen, int rounds, uint8_t *key, size_t keylen)
{
char pass[1024];
+ int rppflags = RPP_ECHO_OFF;
if (rounds == 0) {
memset(key, 0, keylen);
return;
}
- if (!readpassphrase("passphrase: ", pass, sizeof(pass), RPP_ECHO_OFF))
+ if (!isatty(STDIN_FILENO))
+ rppflags |= RPP_STDIN;
+ if (!readpassphrase("passphrase: ", pass, sizeof(pass), rppflags))
errx(1, "unable to read passphrase");
if (strlen(pass) == 0)
errx(1, "please provide a password");