comparison cli-auth.c @ 478:d4f32c3443ac dbclient-netcat-alike

propagate from branch 'au.asn.ucc.matt.dropbear' (head f21045c791002d81fc6b8dde6537ea481e513eb2) to branch 'au.asn.ucc.matt.dropbear.dbclient-netcat-alike' (head d1f69334581dc4c35f9ca16aa5355074c9dd315d)
author Matt Johnston <matt@ucc.asn.au>
date Sun, 14 Sep 2008 06:47:51 +0000
parents fdf06a5a54e4
children d58c478bd399
comparison
equal deleted inserted replaced
296:6b41e2cbf071 478:d4f32c3443ac
234 cli_ses.lastauthtype = AUTH_TYPE_NONE; 234 cli_ses.lastauthtype = AUTH_TYPE_NONE;
235 } 235 }
236 236
237 void cli_auth_try() { 237 void cli_auth_try() {
238 238
239 int finished = 0;
239 TRACE(("enter cli_auth_try")) 240 TRACE(("enter cli_auth_try"))
240 int finished = 0;
241 241
242 CHECKCLEARTOWRITE(); 242 CHECKCLEARTOWRITE();
243 243
244 /* Order to try is pubkey, interactive, password. 244 /* Order to try is pubkey, interactive, password.
245 * As soon as "finished" is set for one, we don't do any more. */ 245 * As soon as "finished" is set for one, we don't do any more. */
279 TRACE(("leave cli_auth_try")) 279 TRACE(("leave cli_auth_try"))
280 } 280 }
281 281
282 /* A helper for getpass() that exits if the user cancels. The returned 282 /* A helper for getpass() that exits if the user cancels. The returned
283 * password is statically allocated by getpass() */ 283 * password is statically allocated by getpass() */
284 char* getpass_or_cancel() 284 char* getpass_or_cancel(char* prompt)
285 { 285 {
286 char* password = NULL; 286 char* password = NULL;
287 287
288 password = getpass("Password: "); 288 #ifdef DROPBEAR_PASSWORD_ENV
289 /* Password provided in an environment var */
290 password = getenv(DROPBEAR_PASSWORD_ENV);
291 if (password)
292 {
293 return password;
294 }
295 #endif
296
297 password = getpass(prompt);
289 298
290 /* 0x03 is a ctrl-c character in the buffer. */ 299 /* 0x03 is a ctrl-c character in the buffer. */
291 if (password == NULL || strchr(password, '\3') != NULL) { 300 if (password == NULL || strchr(password, '\3') != NULL) {
292 dropbear_close("Interrupted."); 301 dropbear_close("Interrupted.");
293 } 302 }