Mercurial > dropbear
comparison cli-auth.c @ 441:fdf06a5a54e4
Allow reading dbclient password from an environment var
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 17 Mar 2007 06:30:11 +0000 |
parents | 8f3ec7c104d9 |
children | d58c478bd399 |
comparison
equal
deleted
inserted
replaced
440:91939c8c2572 | 441:fdf06a5a54e4 |
---|---|
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(char* prompt) | 284 char* getpass_or_cancel(char* prompt) |
285 { | 285 { |
286 char* password = NULL; | 286 char* password = NULL; |
287 | |
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 | |
287 | 296 |
288 password = getpass(prompt); | 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) { |