Mercurial > dropbear
comparison cli-auth.c @ 268:475a818dd6e7
Cancel a dbclient password prompt if the user presses ctrl-c.
Enter still has to be pressed since glibc blocks ctrl-c in getpass()
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 15 Jan 2006 06:43:24 +0000 |
parents | efbaf6b03837 |
children | 64abb124763d baea1d43e7eb |
comparison
equal
deleted
inserted
replaced
267:7ce577234a10 | 268:475a818dd6e7 |
---|---|
276 dropbear_exit("No auth methods could be used."); | 276 dropbear_exit("No auth methods could be used."); |
277 } | 277 } |
278 | 278 |
279 TRACE(("leave cli_auth_try")) | 279 TRACE(("leave cli_auth_try")) |
280 } | 280 } |
281 | |
282 /* A helper for getpass() that exits if the user cancels. The returned | |
283 * password is statically allocated by getpass() */ | |
284 char* getpass_or_cancel() | |
285 { | |
286 char* password = NULL; | |
287 | |
288 password = getpass("Password: "); | |
289 | |
290 /* 0x03 is a ctrl-c character in the buffer. */ | |
291 if (password == NULL || strchr(password, '\3') != NULL) { | |
292 dropbear_close("Interrupted."); | |
293 } | |
294 return password; | |
295 } |