comparison cli-authpasswd.c @ 463:33d5e9fb0f78 agent-client

propagate from branch 'au.asn.ucc.matt.dropbear' (head fb7080ca6e254faaf7cfaee93b0ab6ab6de4ed59) to branch 'au.asn.ucc.matt.dropbear.cli-agent' (head 78d02301ae8310efa2639f15da0ea62dea110e4b)
author Matt Johnston <matt@ucc.asn.au>
date Thu, 29 Nov 2007 11:38:06 +0000
parents bde853a9e680
children c45d65392c1a
comparison
equal deleted inserted replaced
458:c1e9c81d1d27 463:33d5e9fb0f78
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));