diff cli-auth.c @ 278:e109fb08b8ee

merge of 4cbdd6e0a0d8c061075b9ed7609a06c4547f67d3 and 5d396842815593611f0d61762440145d1fc74d5a
author Matt Johnston <matt@ucc.asn.au>
date Wed, 08 Mar 2006 12:53:09 +0000
parents 475a818dd6e7
children 64abb124763d baea1d43e7eb
line wrap: on
line diff
--- a/cli-auth.c	Wed Mar 08 12:09:02 2006 +0000
+++ b/cli-auth.c	Wed Mar 08 12:53:09 2006 +0000
@@ -278,3 +278,18 @@
 
 	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;
+}