Cancel a dbclient password prompt if the user presses ctrl-c.

Enter still has to be pressed since glibc blocks ctrl-c in getpass()

--HG--
extra : convert_revision : 1c8128fba89431f2460dd5914f0614850d529b76
This commit is contained in:
Matt Johnston
2006-01-15 06:43:24 +00:00
parent d8e61e51de
commit fd0f873a36
4 changed files with 18 additions and 5 deletions

View File

@@ -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;
}