Mercurial > dropbear
annotate cli-auth.c @ 1659:d32bcb5c557d
Add Ed25519 support (#91)
* Add support for Ed25519 as a public key type
Ed25519 is a elliptic curve signature scheme that offers
better security than ECDSA and DSA and good performance. It may be
used for both user and host keys.
OpenSSH key import and fuzzer are not supported yet.
Initially inspired by Peter Szabo.
* Add curve25519 and ed25519 fuzzers
* Add import and export of Ed25519 keys
author | Vladislav Grishenko <themiron@users.noreply.github.com> |
---|---|
date | Wed, 11 Mar 2020 21:09:45 +0500 |
parents | 6c16a05023aa |
children | bf1912d2d6e9 |
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 * Copyright (c) 2004 by Mihnea Stoenescu |
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 * 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
|
7 * |
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 * 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
|
9 * 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
|
10 * 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
|
11 * 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
|
12 * 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
|
13 * 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
|
14 * |
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 * 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
|
16 * 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
|
17 * |
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 * 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
|
19 * 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
|
20 * 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
|
21 * 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
|
22 * 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
|
23 * 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
|
24 * 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
|
25 |
33 | 26 #include "includes.h" |
27 #include "session.h" | |
28 #include "auth.h" | |
29 #include "dbutil.h" | |
30 #include "buffer.h" | |
31 #include "ssh.h" | |
32 #include "packet.h" | |
33 #include "runopts.h" | |
34 | |
35 void cli_authinitialise() { | |
36 | |
37 memset(&ses.authstate, 0, sizeof(ses.authstate)); | |
38 } | |
39 | |
40 | |
41 /* Send a "none" auth request to get available methods */ | |
42 void cli_auth_getmethods() { | |
165
0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents:
114
diff
changeset
|
43 TRACE(("enter cli_auth_getmethods")) |
33 | 44 CHECKCLEARTOWRITE(); |
45 buf_putbyte(ses.writepayload, SSH_MSG_USERAUTH_REQUEST); | |
1122
aaf576b27a10
Merge pull request #13 from gazoo74/fix-warnings
Matt Johnston <matt@ucc.asn.au>
parents:
1115
diff
changeset
|
46 buf_putstring(ses.writepayload, cli_opts.username, |
35
0ad5fb979f42
set the isserver flag (oops)
Matt Johnston <matt@ucc.asn.au>
parents:
34
diff
changeset
|
47 strlen(cli_opts.username)); |
1122
aaf576b27a10
Merge pull request #13 from gazoo74/fix-warnings
Matt Johnston <matt@ucc.asn.au>
parents:
1115
diff
changeset
|
48 buf_putstring(ses.writepayload, SSH_SERVICE_CONNECTION, |
33 | 49 SSH_SERVICE_CONNECTION_LEN); |
1122
aaf576b27a10
Merge pull request #13 from gazoo74/fix-warnings
Matt Johnston <matt@ucc.asn.au>
parents:
1115
diff
changeset
|
50 buf_putstring(ses.writepayload, "none", 4); /* 'none' method */ |
33 | 51 |
52 encrypt_packet(); | |
883
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
53 |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1249
diff
changeset
|
54 #if DROPBEAR_CLI_IMMEDIATE_AUTH |
894
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
55 /* We can't haven't two auth requests in-flight with delayed zlib mode |
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
56 since if the first one succeeds then the remote side will |
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
57 expect the second one to be compressed. |
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
58 Race described at |
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
59 http://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/zlib-openssh.html |
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
60 */ |
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
61 if (ses.keys->trans.algo_comp != DROPBEAR_COMP_ZLIB_DELAY) { |
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
62 ses.authstate.authtypes = AUTH_TYPE_PUBKEY; |
1514
6c16a05023aa
rename some options and move some to sysoptions.h
Matt Johnston <matt@ucc.asn.au>
parents:
1499
diff
changeset
|
63 #if DROPBEAR_USE_PASSWORD_ENV |
894
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
64 if (getenv(DROPBEAR_PASSWORD_ENV)) { |
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
65 ses.authstate.authtypes |= AUTH_TYPE_PASSWORD | AUTH_TYPE_INTERACT; |
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
66 } |
1499
2d450c1056e3
options: Complete the transition to numeric toggles (`#if')
Michael Witten <mfwitten@gmail.com>
parents:
1459
diff
changeset
|
67 #endif |
894
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
68 if (cli_auth_try() == DROPBEAR_SUCCESS) { |
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
69 TRACE(("skipped initial none auth query")) |
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
70 /* Note that there will be two auth responses in-flight */ |
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
71 cli_ses.ignore_next_auth_response = 1; |
7032deca6b90
Disable immediate auth for delayed-zlib mode
Matt Johnston <matt@ucc.asn.au>
parents:
883
diff
changeset
|
72 } |
883
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
73 } |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
74 #endif |
165
0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents:
114
diff
changeset
|
75 TRACE(("leave cli_auth_getmethods")) |
33 | 76 } |
77 | |
43 | 78 void recv_msg_userauth_banner() { |
79 | |
1115
efb7e545a65e
Turn banner, methods and tok local variable into char *
Gaël PORTAY <gael.portay@gmail.com>
parents:
1094
diff
changeset
|
80 char* banner = NULL; |
43 | 81 unsigned int bannerlen; |
82 unsigned int i, linecount; | |
1296
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
83 int truncated = 0; |
43 | 84 |
165
0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents:
114
diff
changeset
|
85 TRACE(("enter recv_msg_userauth_banner")) |
43 | 86 if (ses.authstate.authdone) { |
165
0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents:
114
diff
changeset
|
87 TRACE(("leave recv_msg_userauth_banner: banner after auth done")) |
43 | 88 return; |
89 } | |
90 | |
1122
aaf576b27a10
Merge pull request #13 from gazoo74/fix-warnings
Matt Johnston <matt@ucc.asn.au>
parents:
1115
diff
changeset
|
91 banner = buf_getstring(ses.payload, &bannerlen); |
43 | 92 buf_eatstring(ses.payload); /* The language string */ |
93 | |
94 if (bannerlen > MAX_BANNER_SIZE) { | |
165
0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents:
114
diff
changeset
|
95 TRACE(("recv_msg_userauth_banner: bannerlen too long: %d", bannerlen)) |
1296
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
96 truncated = 1; |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
97 } else { |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
98 cleantext(banner); |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
99 |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
100 /* Limit to 24 lines */ |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
101 linecount = 1; |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
102 for (i = 0; i < bannerlen; i++) { |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
103 if (banner[i] == '\n') { |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
104 if (linecount >= MAX_BANNER_LINES) { |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
105 banner[i] = '\0'; |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
106 truncated = 1; |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
107 break; |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
108 } |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
109 linecount++; |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
110 } |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
111 } |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
112 fprintf(stderr, "%s\n", banner); |
43 | 113 } |
114 | |
1296
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
115 if (truncated) { |
6959c88c8f13
message about truncated banner
Matt Johnston <matt@ucc.asn.au>
parents:
1295
diff
changeset
|
116 fprintf(stderr, "[Banner from the server is too long]\n"); |
43 | 117 } |
118 | |
119 m_free(banner); | |
165
0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents:
114
diff
changeset
|
120 TRACE(("leave recv_msg_userauth_banner")) |
43 | 121 } |
122 | |
249
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
123 /* This handles the message-specific types which |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
124 * all have a value of 60. These are |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
125 * SSH_MSG_USERAUTH_PASSWD_CHANGEREQ, |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
126 * SSH_MSG_USERAUTH_PK_OK, & |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
127 * SSH_MSG_USERAUTH_INFO_REQUEST. */ |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
128 void recv_msg_userauth_specific_60() { |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
129 |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1249
diff
changeset
|
130 #if DROPBEAR_CLI_PUBKEY_AUTH |
249
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
131 if (cli_ses.lastauthtype == AUTH_TYPE_PUBKEY) { |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
132 recv_msg_userauth_pk_ok(); |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
133 return; |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
134 } |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
135 #endif |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
136 |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1249
diff
changeset
|
137 #if DROPBEAR_CLI_INTERACT_AUTH |
249
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
138 if (cli_ses.lastauthtype == AUTH_TYPE_INTERACT) { |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
139 recv_msg_userauth_info_request(); |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
140 return; |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
141 } |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
142 #endif |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
143 |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1249
diff
changeset
|
144 #if DROPBEAR_CLI_PASSWORD_AUTH |
249
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
145 if (cli_ses.lastauthtype == AUTH_TYPE_PASSWORD) { |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
146 /* Eventually there could be proper password-changing |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
147 * support. However currently few servers seem to |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
148 * implement it, and password auth is last-resort |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
149 * regardless - keyboard-interactive is more likely |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
150 * to be used anyway. */ |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
151 dropbear_close("Your password has expired."); |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
152 } |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
153 #endif |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
154 |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
155 dropbear_exit("Unexpected userauth packet"); |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
156 } |
43 | 157 |
33 | 158 void recv_msg_userauth_failure() { |
159 | |
1115
efb7e545a65e
Turn banner, methods and tok local variable into char *
Gaël PORTAY <gael.portay@gmail.com>
parents:
1094
diff
changeset
|
160 char * methods = NULL; |
efb7e545a65e
Turn banner, methods and tok local variable into char *
Gaël PORTAY <gael.portay@gmail.com>
parents:
1094
diff
changeset
|
161 char * tok = NULL; |
33 | 162 unsigned int methlen = 0; |
163 unsigned int partial = 0; | |
164 unsigned int i = 0; | |
165 | |
165
0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents:
114
diff
changeset
|
166 TRACE(("<- MSG_USERAUTH_FAILURE")) |
0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents:
114
diff
changeset
|
167 TRACE(("enter recv_msg_userauth_failure")) |
33 | 168 |
883
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
169 if (ses.authstate.authdone) { |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
170 TRACE(("leave recv_msg_userauth_failure, already authdone.")) |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
171 return; |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
172 } |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
173 |
45
9ee8996a375f
Pubkey auth is mostly there for the client. Something strange with
Matt Johnston <matt@ucc.asn.au>
parents:
43
diff
changeset
|
174 if (cli_ses.state != USERAUTH_REQ_SENT) { |
9ee8996a375f
Pubkey auth is mostly there for the client. Something strange with
Matt Johnston <matt@ucc.asn.au>
parents:
43
diff
changeset
|
175 /* Perhaps we should be more fatal? */ |
249
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
176 dropbear_exit("Unexpected userauth failure"); |
45
9ee8996a375f
Pubkey auth is mostly there for the client. Something strange with
Matt Johnston <matt@ucc.asn.au>
parents:
43
diff
changeset
|
177 } |
9ee8996a375f
Pubkey auth is mostly there for the client. Something strange with
Matt Johnston <matt@ucc.asn.au>
parents:
43
diff
changeset
|
178 |
883
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
179 /* When DROPBEAR_CLI_IMMEDIATE_AUTH is set there will be an initial response for |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
180 the "none" auth request, and then a response to the immediate auth request. |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
181 We need to be careful handling them. */ |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
182 if (cli_ses.ignore_next_auth_response) { |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
183 cli_ses.state = USERAUTH_REQ_SENT; |
931
ac340d3e452e
Fix pubkey auth if the first key presented fails (infinite loop of
Matt Johnston <matt@ucc.asn.au>
parents:
894
diff
changeset
|
184 cli_ses.ignore_next_auth_response = 0; |
ac340d3e452e
Fix pubkey auth if the first key presented fails (infinite loop of
Matt Johnston <matt@ucc.asn.au>
parents:
894
diff
changeset
|
185 TRACE(("leave recv_msg_userauth_failure, ignored response, state set to USERAUTH_REQ_SENT")); |
ac340d3e452e
Fix pubkey auth if the first key presented fails (infinite loop of
Matt Johnston <matt@ucc.asn.au>
parents:
894
diff
changeset
|
186 return; |
883
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
187 } else { |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1249
diff
changeset
|
188 #if DROPBEAR_CLI_PUBKEY_AUTH |
883
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
189 /* If it was a pubkey auth request, we should cross that key |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
190 * off the list. */ |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
191 if (cli_ses.lastauthtype == AUTH_TYPE_PUBKEY) { |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
192 cli_pubkeyfail(); |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
193 } |
45
9ee8996a375f
Pubkey auth is mostly there for the client. Something strange with
Matt Johnston <matt@ucc.asn.au>
parents:
43
diff
changeset
|
194 #endif |
9ee8996a375f
Pubkey auth is mostly there for the client. Something strange with
Matt Johnston <matt@ucc.asn.au>
parents:
43
diff
changeset
|
195 |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1249
diff
changeset
|
196 #if DROPBEAR_CLI_INTERACT_AUTH |
883
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
197 /* If we get a failure message for keyboard interactive without |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
198 * receiving any request info packet, then we don't bother trying |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
199 * keyboard interactive again */ |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
200 if (cli_ses.lastauthtype == AUTH_TYPE_INTERACT |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
201 && !cli_ses.interact_request_received) { |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
202 TRACE(("setting auth_interact_failed = 1")) |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
203 cli_ses.auth_interact_failed = 1; |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
204 } |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
205 #endif |
931
ac340d3e452e
Fix pubkey auth if the first key presented fails (infinite loop of
Matt Johnston <matt@ucc.asn.au>
parents:
894
diff
changeset
|
206 cli_ses.state = USERAUTH_FAIL_RCVD; |
ac340d3e452e
Fix pubkey auth if the first key presented fails (infinite loop of
Matt Johnston <matt@ucc.asn.au>
parents:
894
diff
changeset
|
207 cli_ses.lastauthtype = AUTH_TYPE_NONE; |
249
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
208 } |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
209 |
1122
aaf576b27a10
Merge pull request #13 from gazoo74/fix-warnings
Matt Johnston <matt@ucc.asn.au>
parents:
1115
diff
changeset
|
210 methods = buf_getstring(ses.payload, &methlen); |
33 | 211 |
179
161557a9dde8
* fix longstanding bug with connections being closed on failure to
Matt Johnston <matt@ucc.asn.au>
parents:
165
diff
changeset
|
212 partial = buf_getbool(ses.payload); |
33 | 213 |
214 if (partial) { | |
215 dropbear_log(LOG_INFO, "Authentication partially succeeded, more attempts required"); | |
216 } else { | |
217 ses.authstate.failcount++; | |
218 } | |
219 | |
165
0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents:
114
diff
changeset
|
220 TRACE(("Methods (len %d): '%s'", methlen, methods)) |
33 | 221 |
222 ses.authstate.authdone=0; | |
223 ses.authstate.authtypes=0; | |
224 | |
225 /* Split with nulls rather than commas */ | |
226 for (i = 0; i < methlen; i++) { | |
227 if (methods[i] == ',') { | |
228 methods[i] = '\0'; | |
229 } | |
230 } | |
231 | |
232 tok = methods; /* tok stores the next method we'll compare */ | |
233 for (i = 0; i <= methlen; i++) { | |
234 if (methods[i] == '\0') { | |
165
0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents:
114
diff
changeset
|
235 TRACE(("auth method '%s'", tok)) |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1249
diff
changeset
|
236 #if DROPBEAR_CLI_PUBKEY_AUTH |
33 | 237 if (strncmp(AUTH_METHOD_PUBKEY, tok, |
238 AUTH_METHOD_PUBKEY_LEN) == 0) { | |
239 ses.authstate.authtypes |= AUTH_TYPE_PUBKEY; | |
240 } | |
241 #endif | |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1249
diff
changeset
|
242 #if DROPBEAR_CLI_INTERACT_AUTH |
249
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
243 if (strncmp(AUTH_METHOD_INTERACT, tok, |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
244 AUTH_METHOD_INTERACT_LEN) == 0) { |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
245 ses.authstate.authtypes |= AUTH_TYPE_INTERACT; |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
246 } |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
247 #endif |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1249
diff
changeset
|
248 #if DROPBEAR_CLI_PASSWORD_AUTH |
33 | 249 if (strncmp(AUTH_METHOD_PASSWORD, tok, |
250 AUTH_METHOD_PASSWORD_LEN) == 0) { | |
251 ses.authstate.authtypes |= AUTH_TYPE_PASSWORD; | |
252 } | |
253 #endif | |
34
e2a1eaa19f22
Client mostly works up to password auth
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
254 tok = &methods[i+1]; /* Must make sure we don't use it after the |
e2a1eaa19f22
Client mostly works up to password auth
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
255 last loop, since it'll point to something |
e2a1eaa19f22
Client mostly works up to password auth
Matt Johnston <matt@ucc.asn.au>
parents:
33
diff
changeset
|
256 undefined */ |
33 | 257 } |
258 } | |
259 | |
114
2be6aa26a8c9
Leak found with MallocDebug - it's kinda useful
Matt Johnston <matt@ucc.asn.au>
parents:
74
diff
changeset
|
260 m_free(methods); |
33 | 261 |
165
0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents:
114
diff
changeset
|
262 TRACE(("leave recv_msg_userauth_failure")) |
33 | 263 } |
264 | |
265 void recv_msg_userauth_success() { | |
883
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
266 /* This function can validly get called multiple times |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
267 if DROPBEAR_CLI_IMMEDIATE_AUTH is set */ |
ff597bf2cfb0
DROPBEAR_CLI_AUTH_IMMEDIATE fixed, now enabled by default
Matt Johnston <matt@ucc.asn.au>
parents:
734
diff
changeset
|
268 |
165
0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents:
114
diff
changeset
|
269 TRACE(("received msg_userauth_success")) |
501
d58c478bd399
Add support for [email protected] delayed compression.
Matt Johnston <matt@ucc.asn.au>
parents:
441
diff
changeset
|
270 /* Note: in delayed-zlib mode, setting authdone here |
d58c478bd399
Add support for [email protected] delayed compression.
Matt Johnston <matt@ucc.asn.au>
parents:
441
diff
changeset
|
271 * will enable compression in the transport layer */ |
33 | 272 ses.authstate.authdone = 1; |
37 | 273 cli_ses.state = USERAUTH_SUCCESS_RCVD; |
249
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
274 cli_ses.lastauthtype = AUTH_TYPE_NONE; |
552
de3653483ac0
- Client auth using an agent's key works. Still need to implement client
Matt Johnston <matt@ucc.asn.au>
parents:
545
diff
changeset
|
275 |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1249
diff
changeset
|
276 #if DROPBEAR_CLI_PUBKEY_AUTH |
552
de3653483ac0
- Client auth using an agent's key works. Still need to implement client
Matt Johnston <matt@ucc.asn.au>
parents:
545
diff
changeset
|
277 cli_auth_pubkey_cleanup(); |
de3653483ac0
- Client auth using an agent's key works. Still need to implement client
Matt Johnston <matt@ucc.asn.au>
parents:
545
diff
changeset
|
278 #endif |
33 | 279 } |
280 | |
734
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
281 int cli_auth_try() { |
33 | 282 |
300
baea1d43e7eb
Some cleanups/fixes for various TRACE statements
Matt Johnston <matt@ucc.asn.au>
parents:
268
diff
changeset
|
283 int finished = 0; |
165
0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents:
114
diff
changeset
|
284 TRACE(("enter cli_auth_try")) |
33 | 285 |
286 CHECKCLEARTOWRITE(); | |
287 | |
249
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
288 /* Order to try is pubkey, interactive, password. |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
289 * As soon as "finished" is set for one, we don't do any more. */ |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1249
diff
changeset
|
290 #if DROPBEAR_CLI_PUBKEY_AUTH |
33 | 291 if (ses.authstate.authtypes & AUTH_TYPE_PUBKEY) { |
292 finished = cli_auth_pubkey(); | |
45
9ee8996a375f
Pubkey auth is mostly there for the client. Something strange with
Matt Johnston <matt@ucc.asn.au>
parents:
43
diff
changeset
|
293 cli_ses.lastauthtype = AUTH_TYPE_PUBKEY; |
33 | 294 } |
295 #endif | |
296 | |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1249
diff
changeset
|
297 #if DROPBEAR_CLI_PASSWORD_AUTH |
734
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
298 if (!finished && (ses.authstate.authtypes & AUTH_TYPE_PASSWORD)) { |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
299 if (ses.keys->trans.algo_crypt->cipherdesc == NULL) { |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
300 fprintf(stderr, "Sorry, I won't let you use password auth unencrypted.\n"); |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
301 } else { |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
302 cli_auth_password(); |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
303 finished = 1; |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
304 cli_ses.lastauthtype = AUTH_TYPE_PASSWORD; |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
305 } |
732
2e5f2bc60e40
Try password before interactive - bit of a hack
Matt Johnston <matt@ucc.asn.au>
parents:
730
diff
changeset
|
306 } |
2e5f2bc60e40
Try password before interactive - bit of a hack
Matt Johnston <matt@ucc.asn.au>
parents:
730
diff
changeset
|
307 #endif |
2e5f2bc60e40
Try password before interactive - bit of a hack
Matt Johnston <matt@ucc.asn.au>
parents:
730
diff
changeset
|
308 |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1249
diff
changeset
|
309 #if DROPBEAR_CLI_INTERACT_AUTH |
734
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
310 if (!finished && (ses.authstate.authtypes & AUTH_TYPE_INTERACT)) { |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
311 if (ses.keys->trans.algo_crypt->cipherdesc == NULL) { |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
312 fprintf(stderr, "Sorry, I won't let you use interactive auth unencrypted.\n"); |
249
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
313 } else { |
734
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
314 if (!cli_ses.auth_interact_failed) { |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
315 cli_auth_interactive(); |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
316 cli_ses.lastauthtype = AUTH_TYPE_INTERACT; |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
317 finished = 1; |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
318 } |
249
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
319 } |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
320 } |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
321 #endif |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
322 |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
323 TRACE(("cli_auth_try lastauthtype %d", cli_ses.lastauthtype)) |
efbaf6b03837
added keyboard-interactive client support
Matt Johnston <matt@ucc.asn.au>
parents:
179
diff
changeset
|
324 |
734
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
325 if (finished) { |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
326 TRACE(("leave cli_auth_try success")) |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
327 return DROPBEAR_SUCCESS; |
33 | 328 } |
734
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
329 TRACE(("leave cli_auth_try failure")) |
619b1ed837fd
Be a bit more careful about when we want to use CLI_AUTH_IMMEDIATE
Matt Johnston <matt@ucc.asn.au>
parents:
732
diff
changeset
|
330 return DROPBEAR_FAILURE; |
33 | 331 } |
268
475a818dd6e7
Cancel a dbclient password prompt if the user presses ctrl-c.
Matt Johnston <matt@ucc.asn.au>
parents:
249
diff
changeset
|
332 |
1295
750ec4ec4cbe
Convert #ifdef to #if, other build changes
Matt Johnston <matt@ucc.asn.au>
parents:
1249
diff
changeset
|
333 #if DROPBEAR_CLI_PASSWORD_AUTH || DROPBEAR_CLI_INTERACT_AUTH |
268
475a818dd6e7
Cancel a dbclient password prompt if the user presses ctrl-c.
Matt Johnston <matt@ucc.asn.au>
parents:
249
diff
changeset
|
334 /* A helper for getpass() that exits if the user cancels. The returned |
475a818dd6e7
Cancel a dbclient password prompt if the user presses ctrl-c.
Matt Johnston <matt@ucc.asn.au>
parents:
249
diff
changeset
|
335 * password is statically allocated by getpass() */ |
1459
06d52bcb8094
Pointer parameter could be declared as pointing to const
Francois Perrad <francois.perrad@gadz.org>
parents:
1296
diff
changeset
|
336 char* getpass_or_cancel(const char* prompt) |
268
475a818dd6e7
Cancel a dbclient password prompt if the user presses ctrl-c.
Matt Johnston <matt@ucc.asn.au>
parents:
249
diff
changeset
|
337 { |
475a818dd6e7
Cancel a dbclient password prompt if the user presses ctrl-c.
Matt Johnston <matt@ucc.asn.au>
parents:
249
diff
changeset
|
338 char* password = NULL; |
441
fdf06a5a54e4
Allow reading dbclient password from an environment var
Matt Johnston <matt@ucc.asn.au>
parents:
334
diff
changeset
|
339 |
1514
6c16a05023aa
rename some options and move some to sysoptions.h
Matt Johnston <matt@ucc.asn.au>
parents:
1499
diff
changeset
|
340 #if DROPBEAR_USE_PASSWORD_ENV |
1249
c6346c63281b
refactor indentation with hard tab
Francois Perrad <francois.perrad@gadz.org>
parents:
1156
diff
changeset
|
341 /* Password provided in an environment var */ |
c6346c63281b
refactor indentation with hard tab
Francois Perrad <francois.perrad@gadz.org>
parents:
1156
diff
changeset
|
342 password = getenv(DROPBEAR_PASSWORD_ENV); |
c6346c63281b
refactor indentation with hard tab
Francois Perrad <francois.perrad@gadz.org>
parents:
1156
diff
changeset
|
343 if (password) |
c6346c63281b
refactor indentation with hard tab
Francois Perrad <francois.perrad@gadz.org>
parents:
1156
diff
changeset
|
344 { |
c6346c63281b
refactor indentation with hard tab
Francois Perrad <francois.perrad@gadz.org>
parents:
1156
diff
changeset
|
345 return password; |
c6346c63281b
refactor indentation with hard tab
Francois Perrad <francois.perrad@gadz.org>
parents:
1156
diff
changeset
|
346 } |
441
fdf06a5a54e4
Allow reading dbclient password from an environment var
Matt Johnston <matt@ucc.asn.au>
parents:
334
diff
changeset
|
347 #endif |
268
475a818dd6e7
Cancel a dbclient password prompt if the user presses ctrl-c.
Matt Johnston <matt@ucc.asn.au>
parents:
249
diff
changeset
|
348 |
334
8f3ec7c104d9
Make the dbclient password prompt more useful
Matt Johnston <matt@ucc.asn.au>
parents:
300
diff
changeset
|
349 password = getpass(prompt); |
268
475a818dd6e7
Cancel a dbclient password prompt if the user presses ctrl-c.
Matt Johnston <matt@ucc.asn.au>
parents:
249
diff
changeset
|
350 |
475a818dd6e7
Cancel a dbclient password prompt if the user presses ctrl-c.
Matt Johnston <matt@ucc.asn.au>
parents:
249
diff
changeset
|
351 /* 0x03 is a ctrl-c character in the buffer. */ |
475a818dd6e7
Cancel a dbclient password prompt if the user presses ctrl-c.
Matt Johnston <matt@ucc.asn.au>
parents:
249
diff
changeset
|
352 if (password == NULL || strchr(password, '\3') != NULL) { |
475a818dd6e7
Cancel a dbclient password prompt if the user presses ctrl-c.
Matt Johnston <matt@ucc.asn.au>
parents:
249
diff
changeset
|
353 dropbear_close("Interrupted."); |
475a818dd6e7
Cancel a dbclient password prompt if the user presses ctrl-c.
Matt Johnston <matt@ucc.asn.au>
parents:
249
diff
changeset
|
354 } |
475a818dd6e7
Cancel a dbclient password prompt if the user presses ctrl-c.
Matt Johnston <matt@ucc.asn.au>
parents:
249
diff
changeset
|
355 return password; |
475a818dd6e7
Cancel a dbclient password prompt if the user presses ctrl-c.
Matt Johnston <matt@ucc.asn.au>
parents:
249
diff
changeset
|
356 } |
1156
a8f4dade70e5
avoid getpass when not used
Mike Frysinger <vapier@gentoo.org>
parents:
1122
diff
changeset
|
357 #endif |