summaryrefslogtreecommitdiff
path: root/cli-auth.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2006-01-15 06:43:24 +0000
committerMatt Johnston <matt@ucc.asn.au>2006-01-15 06:43:24 +0000
commit0a99145750994c66008be1d95bdc8690db926c05 (patch)
tree95cd089b6b5b7e07e9d8fdaa03dbfb5aa6fffab4 /cli-auth.c
parentfd67055c8ca4182f0c27dad63052b441b0104314 (diff)
downloaddropbear-0a99145750994c66008be1d95bdc8690db926c05.tar.gz
Cancel a dbclient password prompt if the user presses ctrl-c.
Enter still has to be pressed since glibc blocks ctrl-c in getpass()
Diffstat (limited to 'cli-auth.c')
-rw-r--r--cli-auth.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/cli-auth.c b/cli-auth.c
index 6a6d53a..d08de9a 100644
--- a/cli-auth.c
+++ b/cli-auth.c
@@ -278,3 +278,18 @@ void cli_auth_try() {
TRACE(("leave cli_auth_try"))
}
+
+/* A helper for getpass() that exits if the user cancels. The returned
+ * password is statically allocated by getpass() */
+char* getpass_or_cancel()
+{
+ char* password = NULL;
+
+ password = getpass("Password: ");
+
+ /* 0x03 is a ctrl-c character in the buffer. */
+ if (password == NULL || strchr(password, '\3') != NULL) {
+ dropbear_close("Interrupted.");
+ }
+ return password;
+}