summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2014-03-06 20:04:45 +0000
committertedu <tedu@openbsd.org>2014-03-06 20:04:45 +0000
commit2adf8afccfe1dfba742fbc8e51285c29ab1a0096 (patch)
treef685b155404f3723e02a756490b5a83a34f331d6
parentMake sure we don't attach to those silly AMI MegaRAIDs that expose the (diff)
downloadwireguard-openbsd-2adf8afccfe1dfba742fbc8e51285c29ab1a0096.tar.xz
wireguard-openbsd-2adf8afccfe1dfba742fbc8e51285c29ab1a0096.zip
allow password on stdin if it's not a tty. commonly requested.
-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");