aboutsummaryrefslogtreecommitdiffstats
path: root/src/passphrase.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-11-22 10:37:49 +0100
committerMattias Andrée <maandree@operamail.com>2013-11-22 10:37:49 +0100
commiteb4d860255ea9e0aa9c2a758ba074ac224c029e5 (patch)
tree6509f345347b3c3ba89c61ac27816d57855e573c /src/passphrase.c
parentadd install and uninstall to makefile (diff)
downloadlibpassphrase-eb4d860255ea9e0aa9c2a758ba074ac224c029e5.tar.gz
libpassphrase-eb4d860255ea9e0aa9c2a758ba074ac224c029e5.tar.bz2
libpassphrase-eb4d860255ea9e0aa9c2a758ba074ac224c029e5.tar.xz
optionally do not hide the input
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/passphrase.c')
-rw-r--r--src/passphrase.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/passphrase.c b/src/passphrase.c
index 724ff09..43f1431 100644
--- a/src/passphrase.c
+++ b/src/passphrase.c
@@ -27,10 +27,12 @@
#define START_PASSPHRASE_LIMIT 32
+#ifndef PASSPHRASE_ECHO
/**
* The original TTY settings
*/
static struct termios saved_stty;
+#endif
/**
@@ -72,7 +74,9 @@ char* passphrase_read(void)
/* NUL-terminate passphrase */
*(rc + len) = 0;
+#ifndef PASSPHRASE_ECHO
printf("\n");
+#endif
return rc;
}
@@ -82,12 +86,14 @@ char* passphrase_read(void)
*/
void passphrase_disable_echo(void)
{
+#ifndef PASSPHRASE_ECHO
struct termios stty;
tcgetattr(STDIN_FILENO, &stty);
saved_stty = stty;
stty.c_lflag &= ~ECHO;
tcsetattr(STDIN_FILENO, TCSAFLUSH, &stty);
+#endif
}
@@ -96,6 +102,8 @@ void passphrase_disable_echo(void)
*/
void passphrase_reenable_echo(void)
{
+#ifndef PASSPHRASE_ECHO
tcsetattr(STDIN_FILENO, TCSAFLUSH, &saved_stty);
+#endif
}