Mercurial > dropbear
comparison cli-authpasswd.c @ 460:bde853a9e680
Add support for SSH_ASKPASS_ALWAYS env variable for dbclient. If it
(and also SSH_ASKPASS) is set then dbclient will use an external askpass
program regardless of whether DISPLAY is set or stdin is a TTY. Suggested
by Davyd Madeley for handheld devices.
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 14 Sep 2007 00:19:44 +0000 |
parents | 8f3ec7c104d9 |
children | c45d65392c1a |
comparison
equal
deleted
inserted
replaced
459:f4addc06745b | 460:bde853a9e680 |
---|---|
36 static int want_askpass() | 36 static int want_askpass() |
37 { | 37 { |
38 char* askpass_prog = NULL; | 38 char* askpass_prog = NULL; |
39 | 39 |
40 askpass_prog = getenv("SSH_ASKPASS"); | 40 askpass_prog = getenv("SSH_ASKPASS"); |
41 return askpass_prog && !isatty(STDIN_FILENO) && getenv("DISPLAY"); | 41 return askpass_prog && |
42 ((!isatty(STDIN_FILENO) && getenv("DISPLAY") ) | |
43 || getenv("SSH_ASKPASS_ALWAYS")); | |
42 } | 44 } |
43 | 45 |
44 /* returns a statically allocated password from a helper app, or NULL | 46 /* returns a statically allocated password from a helper app, or NULL |
45 * on failure */ | 47 * on failure */ |
46 static char *gui_getpass(const char *prompt) { | 48 static char *gui_getpass(const char *prompt) { |
123 | 125 |
124 snprintf(prompt, sizeof(prompt), "%s@%s's password: ", | 126 snprintf(prompt, sizeof(prompt), "%s@%s's password: ", |
125 cli_opts.username, cli_opts.remotehost); | 127 cli_opts.username, cli_opts.remotehost); |
126 #ifdef ENABLE_CLI_ASKPASS_HELPER | 128 #ifdef ENABLE_CLI_ASKPASS_HELPER |
127 if (want_askpass()) | 129 if (want_askpass()) |
130 { | |
128 password = gui_getpass(prompt); | 131 password = gui_getpass(prompt); |
129 else | 132 if (!password) { |
133 dropbear_exit("No password"); | |
134 } | |
135 } else | |
130 #endif | 136 #endif |
137 { | |
131 password = getpass_or_cancel(prompt); | 138 password = getpass_or_cancel(prompt); |
139 } | |
132 | 140 |
133 buf_putbyte(ses.writepayload, SSH_MSG_USERAUTH_REQUEST); | 141 buf_putbyte(ses.writepayload, SSH_MSG_USERAUTH_REQUEST); |
134 | 142 |
135 buf_putstring(ses.writepayload, cli_opts.username, | 143 buf_putstring(ses.writepayload, cli_opts.username, |
136 strlen(cli_opts.username)); | 144 strlen(cli_opts.username)); |