Mercurial > dropbear
annotate cli-authpasswd.c @ 1748:34d9d3c022ce
Use Dropbear's random source rather than libtommath's platform
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 19 Oct 2020 22:49:19 +0800 |
parents | 750ec4ec4cbe |
children | df8d8ec1801c |
rev | line source |
---|---|
74
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
1 /* |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
2 * Dropbear SSH |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
3 * |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
4 * Copyright (c) 2002,2003 Matt Johnston |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
5 * All rights reserved. |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
6 * |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
7 * Permission is hereby granted, free of charge, to any person obtaining a copy |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
8 * of this software and associated documentation files (the "Software"), to deal |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
9 * in the Software without restriction, including without limitation the rights |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
11 * copies of the Software, and to permit persons to whom the Software is |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
12 * furnished to do so, subject to the following conditions: |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
13 * |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
14 * The above copyright notice and this permission notice shall be included in |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
15 * all copies or substantial portions of the Software. |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
16 * |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
23 * SOFTWARE. */ |
e3adf4cf5465
License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents:
68
diff
changeset
|
24 |
33 | 25 #include "includes.h" |
26 #include "buffer.h" | |
27 #include "dbutil.h" | |
28 #include "session.h" | |
29 #include "ssh.h" | |
35
0ad5fb979f42
set the isserver flag (oops)
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
30 #include "runopts.h" |
33 | 31 |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1122
diff
changeset
|
32 #if DROPBEAR_CLI_PASSWORD_AUTH |
173
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
33 |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1122
diff
changeset
|
34 #if DROPBEAR_CLI_ASKPASS_HELPER |
173
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
35 /* Returns 1 if we want to use the askpass program, 0 otherwise */ |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
36 static int want_askpass() |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
37 { |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
38 char* askpass_prog = NULL; |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
39 |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
40 askpass_prog = getenv("SSH_ASKPASS"); |
460
bde853a9e680
Add support for SSH_ASKPASS_ALWAYS env variable for dbclient. If it
Matt Johnston <matt@ucc.asn.au>
parents:
334
diff
changeset
|
41 return askpass_prog && |
bde853a9e680
Add support for SSH_ASKPASS_ALWAYS env variable for dbclient. If it
Matt Johnston <matt@ucc.asn.au>
parents:
334
diff
changeset
|
42 ((!isatty(STDIN_FILENO) && getenv("DISPLAY") ) |
bde853a9e680
Add support for SSH_ASKPASS_ALWAYS env variable for dbclient. If it
Matt Johnston <matt@ucc.asn.au>
parents:
334
diff
changeset
|
43 || getenv("SSH_ASKPASS_ALWAYS")); |
173
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
44 } |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
45 |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
46 /* returns a statically allocated password from a helper app, or NULL |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
47 * on failure */ |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
48 static char *gui_getpass(const char *prompt) { |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
49 |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
50 pid_t pid; |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
51 int p[2], maxlen, len, status; |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
52 static char buf[DROPBEAR_MAX_CLI_PASS + 1]; |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
53 char* helper = NULL; |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
54 |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
55 TRACE(("enter gui_getpass")) |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
56 |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
57 helper = getenv("SSH_ASKPASS"); |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
58 if (!helper) |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
59 { |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
60 TRACE(("leave gui_getpass: no askpass program")) |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
61 return NULL; |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
62 } |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
63 |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
64 if (pipe(p) < 0) { |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
65 TRACE(("error creating child pipe")) |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
66 return NULL; |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
67 } |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
68 |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
69 pid = fork(); |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
70 |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
71 if (pid < 0) { |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
72 TRACE(("fork error")) |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
73 return NULL; |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
74 } |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
75 |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
76 if (!pid) { |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
77 /* child */ |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
78 close(p[0]); |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
79 if (dup2(p[1], STDOUT_FILENO) < 0) { |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
80 TRACE(("error redirecting stdout")) |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
81 exit(1); |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
82 } |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
83 close(p[1]); |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
84 execlp(helper, helper, prompt, (char *)0); |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
85 TRACE(("execlp error")) |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
86 exit(1); |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
87 } |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
88 |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
89 close(p[1]); |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
90 maxlen = sizeof(buf); |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
91 while (maxlen > 0) { |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
92 len = read(p[0], buf + sizeof(buf) - maxlen, maxlen); |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
93 if (len > 0) { |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
94 maxlen -= len; |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
95 } else { |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
96 if (errno != EINTR) |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
97 break; |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
98 } |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
99 } |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
100 |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
101 close(p[0]); |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
102 |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
103 while (waitpid(pid, &status, 0) < 0 && errno == EINTR) |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
104 ; |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
105 if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
106 return(NULL); |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
107 |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
108 len = sizeof(buf) - maxlen; |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
109 buf[len] = '\0'; |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
110 if (len > 0 && buf[len - 1] == '\n') |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
111 buf[len - 1] = '\0'; |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
112 |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
113 TRACE(("leave gui_getpass")) |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
114 return(buf); |
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
115 } |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1122
diff
changeset
|
116 #endif /* DROPBEAR_CLI_ASKPASS_HELPER */ |
173
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
117 |
249
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
173
diff
changeset
|
118 void cli_auth_password() { |
33 | 119 |
120 char* password = NULL; | |
334
8f3ec7c104d9
Make the dbclient password prompt more useful
Matt Johnston <matt@ucc.asn.au>
parents:
268
diff
changeset
|
121 char prompt[80]; |
173
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
122 |
165
0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents:
74
diff
changeset
|
123 TRACE(("enter cli_auth_password")) |
173
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
124 CHECKCLEARTOWRITE(); |
33 | 125 |
334
8f3ec7c104d9
Make the dbclient password prompt more useful
Matt Johnston <matt@ucc.asn.au>
parents:
268
diff
changeset
|
126 snprintf(prompt, sizeof(prompt), "%s@%s's password: ", |
8f3ec7c104d9
Make the dbclient password prompt more useful
Matt Johnston <matt@ucc.asn.au>
parents:
268
diff
changeset
|
127 cli_opts.username, cli_opts.remotehost); |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1122
diff
changeset
|
128 #if DROPBEAR_CLI_ASKPASS_HELPER |
173
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
129 if (want_askpass()) |
460
bde853a9e680
Add support for SSH_ASKPASS_ALWAYS env variable for dbclient. If it
Matt Johnston <matt@ucc.asn.au>
parents:
334
diff
changeset
|
130 { |
334
8f3ec7c104d9
Make the dbclient password prompt more useful
Matt Johnston <matt@ucc.asn.au>
parents:
268
diff
changeset
|
131 password = gui_getpass(prompt); |
460
bde853a9e680
Add support for SSH_ASKPASS_ALWAYS env variable for dbclient. If it
Matt Johnston <matt@ucc.asn.au>
parents:
334
diff
changeset
|
132 if (!password) { |
bde853a9e680
Add support for SSH_ASKPASS_ALWAYS env variable for dbclient. If it
Matt Johnston <matt@ucc.asn.au>
parents:
334
diff
changeset
|
133 dropbear_exit("No password"); |
bde853a9e680
Add support for SSH_ASKPASS_ALWAYS env variable for dbclient. If it
Matt Johnston <matt@ucc.asn.au>
parents:
334
diff
changeset
|
134 } |
bde853a9e680
Add support for SSH_ASKPASS_ALWAYS env variable for dbclient. If it
Matt Johnston <matt@ucc.asn.au>
parents:
334
diff
changeset
|
135 } else |
173
257f09a63dab
* add SSH_ASKPASS support (based on patch from Paul Whittaker
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
136 #endif |
460
bde853a9e680
Add support for SSH_ASKPASS_ALWAYS env variable for dbclient. If it
Matt Johnston <matt@ucc.asn.au>
parents:
334
diff
changeset
|
137 { |
334
8f3ec7c104d9
Make the dbclient password prompt more useful
Matt Johnston <matt@ucc.asn.au>
parents:
268
diff
changeset
|
138 password = getpass_or_cancel(prompt); |
460
bde853a9e680
Add support for SSH_ASKPASS_ALWAYS env variable for dbclient. If it
Matt Johnston <matt@ucc.asn.au>
parents:
334
diff
changeset
|
139 } |
33 | 140 |
141 buf_putbyte(ses.writepayload, SSH_MSG_USERAUTH_REQUEST); | |
142 | |
1122
aaf576b27a10
Merge pull request #13 from gazoo74/fix-warnings
Matt Johnston <matt@ucc.asn.au>
parents:
1094
diff
changeset
|
143 buf_putstring(ses.writepayload, cli_opts.username, |
35
0ad5fb979f42
set the isserver flag (oops)
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
144 strlen(cli_opts.username)); |
33 | 145 |
1122
aaf576b27a10
Merge pull request #13 from gazoo74/fix-warnings
Matt Johnston <matt@ucc.asn.au>
parents:
1094
diff
changeset
|
146 buf_putstring(ses.writepayload, SSH_SERVICE_CONNECTION, |
33 | 147 SSH_SERVICE_CONNECTION_LEN); |
148 | |
1122
aaf576b27a10
Merge pull request #13 from gazoo74/fix-warnings
Matt Johnston <matt@ucc.asn.au>
parents:
1094
diff
changeset
|
149 buf_putstring(ses.writepayload, AUTH_METHOD_PASSWORD, |
33 | 150 AUTH_METHOD_PASSWORD_LEN); |
151 | |
152 buf_putbyte(ses.writepayload, 0); /* FALSE - so says the spec */ | |
153 | |
1122
aaf576b27a10
Merge pull request #13 from gazoo74/fix-warnings
Matt Johnston <matt@ucc.asn.au>
parents:
1094
diff
changeset
|
154 buf_putstring(ses.writepayload, password, strlen(password)); |
33 | 155 |
156 encrypt_packet(); | |
157 m_burn(password, strlen(password)); | |
158 | |
165
0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents:
74
diff
changeset
|
159 TRACE(("leave cli_auth_password")) |
33 | 160 } |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1122
diff
changeset
|
161 #endif /* DROPBEAR_CLI_PASSWORD_AUTH */ |