comparison cli-auth.c @ 511:582cb38e4eb5 insecure-nocrypto

propagate from branch 'au.asn.ucc.matt.dropbear' (head cdcc3c729e29544e8b98a408e2dc60e4483dfd2a) to branch 'au.asn.ucc.matt.dropbear.insecure-nocrypto' (head 0ca38a1cf349f7426ac9de34ebe4c3e3735effab)
author Matt Johnston <matt@ucc.asn.au>
date Thu, 06 Nov 2008 13:16:55 +0000
parents 64abb124763d d58c478bd399
children a4b7627b3157
comparison
equal deleted inserted replaced
361:461c4b1fb35f 511:582cb38e4eb5
227 TRACE(("leave recv_msg_userauth_failure")) 227 TRACE(("leave recv_msg_userauth_failure"))
228 } 228 }
229 229
230 void recv_msg_userauth_success() { 230 void recv_msg_userauth_success() {
231 TRACE(("received msg_userauth_success")) 231 TRACE(("received msg_userauth_success"))
232 /* Note: in delayed-zlib mode, setting authdone here
233 * will enable compression in the transport layer */
232 ses.authstate.authdone = 1; 234 ses.authstate.authdone = 1;
233 cli_ses.state = USERAUTH_SUCCESS_RCVD; 235 cli_ses.state = USERAUTH_SUCCESS_RCVD;
234 cli_ses.lastauthtype = AUTH_TYPE_NONE; 236 cli_ses.lastauthtype = AUTH_TYPE_NONE;
235 } 237 }
236 238
237 void cli_auth_try() { 239 void cli_auth_try() {
238 240
241 int finished = 0;
239 TRACE(("enter cli_auth_try")) 242 TRACE(("enter cli_auth_try"))
240 int finished = 0;
241 243
242 CHECKCLEARTOWRITE(); 244 CHECKCLEARTOWRITE();
243 245
244 /* Order to try is pubkey, interactive, password. 246 /* Order to try is pubkey, interactive, password.
245 * As soon as "finished" is set for one, we don't do any more. */ 247 * As soon as "finished" is set for one, we don't do any more. */
285 TRACE(("leave cli_auth_try")) 287 TRACE(("leave cli_auth_try"))
286 } 288 }
287 289
288 /* A helper for getpass() that exits if the user cancels. The returned 290 /* A helper for getpass() that exits if the user cancels. The returned
289 * password is statically allocated by getpass() */ 291 * password is statically allocated by getpass() */
290 char* getpass_or_cancel() 292 char* getpass_or_cancel(char* prompt)
291 { 293 {
292 char* password = NULL; 294 char* password = NULL;
293 295
294 password = getpass("Password: "); 296 #ifdef DROPBEAR_PASSWORD_ENV
297 /* Password provided in an environment var */
298 password = getenv(DROPBEAR_PASSWORD_ENV);
299 if (password)
300 {
301 return password;
302 }
303 #endif
304
305 password = getpass(prompt);
295 306
296 /* 0x03 is a ctrl-c character in the buffer. */ 307 /* 0x03 is a ctrl-c character in the buffer. */
297 if (password == NULL || strchr(password, '\3') != NULL) { 308 if (password == NULL || strchr(password, '\3') != NULL) {
298 dropbear_close("Interrupted."); 309 dropbear_close("Interrupted.");
299 } 310 }