Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | extern ServerOptions options; | - |
10 | | - |
11 | static int auth2_challenge_start(struct ssh *); | - |
12 | static int send_userauth_info_request(struct ssh *); | - |
13 | static int input_userauth_info_response(int, u_int32_t, struct ssh *); | - |
14 | KbdintDevice *devices[] = { | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | ((void *)0) | - |
24 | | - |
25 | }; | - |
26 | | - |
27 | typedef struct KbdintAuthctxt KbdintAuthctxt; | - |
28 | struct KbdintAuthctxt | - |
29 | { | - |
30 | char *devices; | - |
31 | void *ctxt; | - |
32 | KbdintDevice *device; | - |
33 | u_int nreq; | - |
34 | u_int devices_done; | - |
35 | }; | - |
36 | static KbdintAuthctxt * | - |
37 | kbdint_alloc(const char *devs) | - |
38 | { | - |
39 | KbdintAuthctxt *kbdintctxt; | - |
40 | struct sshbuf *b; | - |
41 | int i, r; | - |
42 | | - |
43 | | - |
44 | | - |
45 | | - |
46 | | - |
47 | | - |
48 | kbdintctxt = xcalloc(1, sizeof(KbdintAuthctxt)); | - |
49 | if ( | - |
50 | __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
51 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
52 | ) && __builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
53 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
54 | ) && (__s1_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
55 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
56 | ), __s2_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
57 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
58 | ), (!((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
59 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
60 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
61 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
62 | ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
63 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
64 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
65 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
66 | ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
67 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
68 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
69 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
70 | ) : (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
71 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
72 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
73 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
74 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
75 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
76 | ) == 1) && (__s1_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
77 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
78 | ), __s1_len < 4) ? (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
79 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
80 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
81 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
82 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
83 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
84 | ) == 1) ? __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
85 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
86 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
87 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
88 | ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
89 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
90 | ); int __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
91 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
92 | ))[0] - __s2[0]); if (__s1_len > 0TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
93 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
94 | ))[1] - __s2[1]); if (__s1_len > 1TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
95 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
96 | ))[2] - __s2[2]); if (__s1_len > 2TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) __result = (((const unsigned char *) (const char *) (never executed: __result = (((const unsigned char *) (const char *) ( devs ))[3] - __s2[3]); | 0 |
97 | devsTRUE | never evaluated | FALSE | never evaluated |
never executed: __result = (((const unsigned char *) (const char *) ( devs ))[3] - __s2[3]); | 0 |
98 | ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
99 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
100 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
101 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
102 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
103 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
104 | ) == 1) && (__s2_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
105 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
106 | ), __s2_len < 4) ? (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
107 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
108 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
109 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
110 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
111 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
112 | ) == 1) ? __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
113 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
114 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
115 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
116 | ) : -(__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
117 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
118 | ); int __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
119 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
120 | ))[0] - __s2[0]); if (__s2_len > 0TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
121 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
122 | ))[1] - __s2[1]); if (__s2_len > 1TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
123 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
124 | ))[2] - __s2[2]); if (__s2_len > 2TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) __result = (((const unsigned char *) (const char *) (never executed: __result = (((const unsigned char *) (const char *) ( "" ))[3] - __s2[3]); | 0 |
125 | ""TRUE | never evaluated | FALSE | never evaluated |
never executed: __result = (((const unsigned char *) (const char *) ( "" ))[3] - __s2[3]); | 0 |
126 | ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
127 | devsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
128 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
129 | ""TRUE | never evaluated | FALSE | never evaluated |
| 0 |
130 | )))); }) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
131 | == 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
132 | if ((TRUE | never evaluated | FALSE | never evaluated |
b = sshbuf_new()) == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
133 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
134 | ) | - |
135 | fatal("%s: sshbuf_new failed", __func__); never executed: fatal("%s: sshbuf_new failed", __func__); | 0 |
136 | for (i = 0; devices[i]TRUE | never evaluated | FALSE | never evaluated |
; i++) { | 0 |
137 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_putf(b, "%s%s",TRUE | never evaluated | FALSE | never evaluated |
| 0 |
138 | sshbuf_len(b) ? "," : "", devices[i]->name)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
139 | fatal("%s: buffer error: %s", never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
140 | __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
141 | } never executed: end of block | 0 |
142 | if ((TRUE | never evaluated | FALSE | never evaluated |
kbdintctxt->devices = sshbuf_dup_string(b)) == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
143 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
144 | ) | - |
145 | fatal("%s: sshbuf_dup_string failed", __func__); never executed: fatal("%s: sshbuf_dup_string failed", __func__); | 0 |
146 | sshbuf_free(b); | - |
147 | } never executed: end of block else { | 0 |
148 | kbdintctxt->devices = xstrdup(devs); | - |
149 | } never executed: end of block | 0 |
150 | debug("kbdint_alloc: devices '%s'", kbdintctxt->devices); | - |
151 | kbdintctxt->ctxt = | - |
152 | ((void *)0) | - |
153 | ; | - |
154 | kbdintctxt->device = | - |
155 | ((void *)0) | - |
156 | ; | - |
157 | kbdintctxt->nreq = 0; | - |
158 | | - |
159 | return never executed: return kbdintctxt; kbdintctxt;never executed: return kbdintctxt; | 0 |
160 | } | - |
161 | static void | - |
162 | kbdint_reset_device(KbdintAuthctxt *kbdintctxt) | - |
163 | { | - |
164 | if (kbdintctxt->ctxtTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
165 | kbdintctxt->device->free_ctx(kbdintctxt->ctxt); | - |
166 | kbdintctxt->ctxt = | - |
167 | ((void *)0) | - |
168 | ; | - |
169 | } never executed: end of block | 0 |
170 | kbdintctxt->device = | - |
171 | ((void *)0) | - |
172 | ; | - |
173 | } never executed: end of block | 0 |
174 | static void | - |
175 | kbdint_free(KbdintAuthctxt *kbdintctxt) | - |
176 | { | - |
177 | if (kbdintctxt->deviceTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
178 | kbdint_reset_device(kbdintctxt); never executed: kbdint_reset_device(kbdintctxt); | 0 |
179 | free(kbdintctxt->devices); | - |
180 | explicit_bzero(kbdintctxt, sizeof(*kbdintctxt)); | - |
181 | free(kbdintctxt); | - |
182 | } never executed: end of block | 0 |
183 | | - |
184 | static int | - |
185 | kbdint_next_device(Authctxt *authctxt, KbdintAuthctxt *kbdintctxt) | - |
186 | { | - |
187 | size_t len; | - |
188 | char *t; | - |
189 | int i; | - |
190 | | - |
191 | if (kbdintctxt->deviceTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
192 | kbdint_reset_device(kbdintctxt); never executed: kbdint_reset_device(kbdintctxt); | 0 |
193 | do { | - |
194 | len = kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
? | 0 |
195 | | - |
196 | __builtin_strcspn ( | - |
197 | kbdintctxt->devices | - |
198 | , | - |
199 | "," | - |
200 | ) | - |
201 | : 0; | - |
202 | | - |
203 | if (len == 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
204 | break; never executed: break; | 0 |
205 | for (i = 0; devices[i]TRUE | never evaluated | FALSE | never evaluated |
; i++) { | 0 |
206 | if ((TRUE | never evaluated | FALSE | never evaluated |
kbdintctxt->devices_done & (1 << i)) != 0TRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
207 | !auth2_method_allowed(authctxt,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
208 | "keyboard-interactive", devices[i]->name)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
209 | continue; never executed: continue; | 0 |
210 | if ( | - |
211 | (TRUE | never evaluated | FALSE | never evaluated |
__extension__ (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
212 | lenTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
213 | )TRUE | never evaluated | FALSE | never evaluated |
&& ((__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
214 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
215 | )TRUE | never evaluated | FALSE | never evaluated |
&& strlen (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
216 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
217 | ) < ((size_t) (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
218 | lenTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
219 | ))TRUE | never evaluated | FALSE | never evaluated |
) || (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
220 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
221 | )TRUE | never evaluated | FALSE | never evaluated |
&& strlen (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
222 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
223 | ) < ((size_t) (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
224 | lenTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
225 | ))TRUE | never evaluated | FALSE | never evaluated |
)) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
226 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
227 | ) && __builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
228 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
229 | ) && (__s1_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
230 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
231 | ), __s2_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
232 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
233 | ), (!((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
234 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
235 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
236 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
237 | ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
238 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
239 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
240 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
241 | ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
242 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
243 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
244 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
245 | ) : (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
246 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
247 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
248 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
249 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
250 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
251 | ) == 1) && (__s1_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
252 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
253 | ), __s1_len < 4) ? (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
254 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
255 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
256 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
257 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
258 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
259 | ) == 1) ? __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
260 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
261 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
262 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
263 | ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
264 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
265 | ); int __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
266 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
267 | ))[0] - __s2[0]); if (__s1_len > 0TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
268 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
269 | ))[1] - __s2[1]); if (__s1_len > 1TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
270 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
271 | ))[2] - __s2[2]); if (__s1_len > 2TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) __result = (((const unsigned char *) (const char *) (never executed: __result = (((const unsigned char *) (const char *) ( kbdintctxt->devices ))[3] - __s2[3]); | 0 |
272 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
never executed: __result = (((const unsigned char *) (const char *) ( kbdintctxt->devices ))[3] - __s2[3]); | 0 |
273 | ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
274 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
275 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
276 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
277 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
278 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
279 | ) == 1) && (__s2_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
280 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
281 | ), __s2_len < 4) ? (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
282 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
283 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
284 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
285 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
286 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
287 | ) == 1) ? __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
288 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
289 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
290 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
291 | ) : -(__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
292 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
293 | ); int __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
294 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
295 | ))[0] - __s2[0]); if (__s2_len > 0TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
296 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
297 | ))[1] - __s2[1]); if (__s2_len > 1TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
298 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
299 | ))[2] - __s2[2]); if (__s2_len > 2TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) __result = (((const unsigned char *) (const char *) (never executed: __result = (((const unsigned char *) (const char *) ( devices[i]->name ))[3] - __s2[3]); | 0 |
300 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
never executed: __result = (((const unsigned char *) (const char *) ( devices[i]->name ))[3] - __s2[3]); | 0 |
301 | ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
302 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
303 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
304 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
305 | )))); }) : strncmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
306 | kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
| 0 |
307 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
308 | devices[i]->nameTRUE | never evaluated | FALSE | never evaluated |
| 0 |
309 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
310 | lenTRUE | never evaluated | FALSE | never evaluated |
| 0 |
311 | )))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
312 | TRUE | never evaluated | FALSE | never evaluated |
| 0 |
313 | == 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
314 | kbdintctxt->device = devices[i]; | - |
315 | kbdintctxt->devices_done |= 1 << i; | - |
316 | } never executed: end of block | 0 |
317 | } never executed: end of block | 0 |
318 | t = kbdintctxt->devices; | - |
319 | kbdintctxt->devices = t[len]TRUE | never evaluated | FALSE | never evaluated |
? xstrdup(t+len+1) : | 0 |
320 | ((void *)0) | - |
321 | ; | - |
322 | free(t); | - |
323 | debug2("kbdint_next_device: devices %s", kbdintctxt->devices ? | - |
324 | kbdintctxt->devices : "<empty>"); | - |
325 | } never executed: end of block while (kbdintctxt->devicesTRUE | never evaluated | FALSE | never evaluated |
&& !kbdintctxt->deviceTRUE | never evaluated | FALSE | never evaluated |
); | 0 |
326 | | - |
327 | return never executed: return kbdintctxt->device ? 1 : 0; kbdintctxt->deviceTRUE | never evaluated | FALSE | never evaluated |
? 1 : 0;never executed: return kbdintctxt->device ? 1 : 0; | 0 |
328 | } | - |
329 | | - |
330 | | - |
331 | | - |
332 | | - |
333 | | - |
334 | int | - |
335 | auth2_challenge(struct ssh *ssh, char *devs) | - |
336 | { | - |
337 | Authctxt *authctxt = ssh->authctxt; | - |
338 | debug("auth2_challenge: user=%s devs=%s", | - |
339 | authctxt->user ? authctxt->user : "<nouser>", | - |
340 | devs ? devs : "<no devs>"); | - |
341 | | - |
342 | if (authctxt->user == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
343 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
344 | || !devsTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
345 | return never executed: return 0; 0;never executed: return 0; | 0 |
346 | if (authctxt->kbdintctxt == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
347 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
348 | ) | - |
349 | authctxt->kbdintctxt = kbdint_alloc(devs); never executed: authctxt->kbdintctxt = kbdint_alloc(devs); | 0 |
350 | return never executed: return auth2_challenge_start(ssh); auth2_challenge_start(ssh);never executed: return auth2_challenge_start(ssh); | 0 |
351 | } | - |
352 | | - |
353 | | - |
354 | void | - |
355 | auth2_challenge_stop(struct ssh *ssh) | - |
356 | { | - |
357 | Authctxt *authctxt = ssh->authctxt; | - |
358 | | - |
359 | ssh_dispatch_set(ssh, 61, | - |
360 | ((void *)0) | - |
361 | ); | - |
362 | if (authctxt->kbdintctxt != TRUE | never evaluated | FALSE | never evaluated |
| 0 |
363 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
364 | ) { | - |
365 | kbdint_free(authctxt->kbdintctxt); | - |
366 | authctxt->kbdintctxt = | - |
367 | ((void *)0) | - |
368 | ; | - |
369 | } never executed: end of block | 0 |
370 | } never executed: end of block | 0 |
371 | | - |
372 | | - |
373 | static int | - |
374 | auth2_challenge_start(struct ssh *ssh) | - |
375 | { | - |
376 | Authctxt *authctxt = ssh->authctxt; | - |
377 | KbdintAuthctxt *kbdintctxt = authctxt->kbdintctxt; | - |
378 | | - |
379 | debug2("auth2_challenge_start: devices %s", | - |
380 | kbdintctxt->devices ? kbdintctxt->devices : "<empty>"); | - |
381 | | - |
382 | if (kbdint_next_device(authctxt, kbdintctxt) == 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
383 | auth2_challenge_stop(ssh); | - |
384 | return never executed: return 0; 0;never executed: return 0; | 0 |
385 | } | - |
386 | debug("auth2_challenge_start: trying authentication method '%s'", | - |
387 | kbdintctxt->device->name); | - |
388 | | - |
389 | if ((TRUE | never evaluated | FALSE | never evaluated |
kbdintctxt->ctxt = kbdintctxt->device->init_ctx(authctxt)) == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
390 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
391 | ) { | - |
392 | auth2_challenge_stop(ssh); | - |
393 | return never executed: return 0; 0;never executed: return 0; | 0 |
394 | } | - |
395 | if (send_userauth_info_request(ssh) == 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
396 | auth2_challenge_stop(ssh); | - |
397 | return never executed: return 0; 0;never executed: return 0; | 0 |
398 | } | - |
399 | ssh_dispatch_set(ssh, 61, | - |
400 | &input_userauth_info_response); | - |
401 | | - |
402 | authctxt->postponed = 1; | - |
403 | return never executed: return 0; 0;never executed: return 0; | 0 |
404 | } | - |
405 | | - |
406 | static int | - |
407 | send_userauth_info_request(struct ssh *ssh) | - |
408 | { | - |
409 | Authctxt *authctxt = ssh->authctxt; | - |
410 | KbdintAuthctxt *kbdintctxt; | - |
411 | char *name, *instr, **prompts; | - |
412 | u_int r, i, *echo_on; | - |
413 | | - |
414 | kbdintctxt = authctxt->kbdintctxt; | - |
415 | if (kbdintctxt->device->query(kbdintctxt->ctxt,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
416 | &name, &instr, &kbdintctxt->nreq, &prompts, &echo_on)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
417 | return never executed: return 0; 0;never executed: return 0; | 0 |
418 | | - |
419 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshpkt_start(ssh, 60)) != 0TRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
420 | (TRUE | never evaluated | FALSE | never evaluated |
r = sshpkt_put_cstring(ssh, name)) != 0TRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
421 | (TRUE | never evaluated | FALSE | never evaluated |
r = sshpkt_put_cstring(ssh, instr)) != 0TRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
422 | (TRUE | never evaluated | FALSE | never evaluated |
r = sshpkt_put_cstring(ssh, "")) != 0TRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
423 | (TRUE | never evaluated | FALSE | never evaluated |
r = sshpkt_put_u32(ssh, kbdintctxt->nreq)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
424 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 |
425 | for (i = 0; i < kbdintctxt->nreqTRUE | never evaluated | FALSE | never evaluated |
; i++) { | 0 |
426 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshpkt_put_cstring(ssh, prompts[i])) != 0TRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
427 | (TRUE | never evaluated | FALSE | never evaluated |
r = sshpkt_put_u8(ssh, echo_on[i])) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
428 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 |
429 | } never executed: end of block | 0 |
430 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshpkt_send(ssh)) != 0TRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
431 | (TRUE | never evaluated | FALSE | never evaluated |
r = ssh_packet_write_wait(ssh)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
432 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 |
433 | | - |
434 | for (i = 0; i < kbdintctxt->nreqTRUE | never evaluated | FALSE | never evaluated |
; i++) | 0 |
435 | free(prompts[i]); never executed: free(prompts[i]); | 0 |
436 | free(prompts); | - |
437 | free(echo_on); | - |
438 | free(name); | - |
439 | free(instr); | - |
440 | return never executed: return 1; 1;never executed: return 1; | 0 |
441 | } | - |
442 | | - |
443 | static int | - |
444 | input_userauth_info_response(int type, u_int32_t seq, struct ssh *ssh) | - |
445 | { | - |
446 | Authctxt *authctxt = ssh->authctxt; | - |
447 | KbdintAuthctxt *kbdintctxt; | - |
448 | int authenticated = 0, res; | - |
449 | int r; | - |
450 | u_int i, nresp; | - |
451 | const char *devicename = | - |
452 | ((void *)0) | - |
453 | ; | - |
454 | char **response = | - |
455 | ((void *)0) | - |
456 | ; | - |
457 | | - |
458 | if (authctxt == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
459 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
460 | ) | - |
461 | fatal("input_userauth_info_response: no authctxt"); never executed: fatal("input_userauth_info_response: no authctxt"); | 0 |
462 | kbdintctxt = authctxt->kbdintctxt; | - |
463 | if (kbdintctxt == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
464 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
465 | || kbdintctxt->ctxt == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
466 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
467 | ) | - |
468 | fatal("input_userauth_info_response: no kbdintctxt"); never executed: fatal("input_userauth_info_response: no kbdintctxt"); | 0 |
469 | if (kbdintctxt->device == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
470 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
471 | ) | - |
472 | fatal("input_userauth_info_response: no device"); never executed: fatal("input_userauth_info_response: no device"); | 0 |
473 | | - |
474 | authctxt->postponed = 0; | - |
475 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshpkt_get_u32(ssh, &nresp)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
476 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 |
477 | if (nresp != kbdintctxt->nreqTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
478 | fatal("input_userauth_info_response: wrong number of replies"); never executed: fatal("input_userauth_info_response: wrong number of replies"); | 0 |
479 | if (nresp > 100TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
480 | fatal("input_userauth_info_response: too many replies"); never executed: fatal("input_userauth_info_response: too many replies"); | 0 |
481 | if (nresp > 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
482 | response = xcalloc(nresp, sizeof(char *)); | - |
483 | for (i = 0; i < nrespTRUE | never evaluated | FALSE | never evaluated |
; i++) | 0 |
484 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshpkt_get_cstring(ssh, &response[i],TRUE | never evaluated | FALSE | never evaluated |
| 0 |
485 | TRUE | never evaluated | FALSE | never evaluated |
| 0 |
486 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
487 | )) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
488 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 |
489 | } never executed: end of block | 0 |
490 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshpkt_get_end(ssh)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
491 | fatal("%s: %s", __func__, ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 |
492 | | - |
493 | res = kbdintctxt->device->respond(kbdintctxt->ctxt, nresp, response); | - |
494 | | - |
495 | for (i = 0; i < nrespTRUE | never evaluated | FALSE | never evaluated |
; i++) { | 0 |
496 | explicit_bzero(response[i], strlen(response[i])); | - |
497 | free(response[i]); | - |
498 | } never executed: end of block | 0 |
499 | free(response); | - |
500 | | - |
501 | switch (res) { | - |
502 | case never executed: case 0: 0:never executed: case 0: | 0 |
503 | | - |
504 | authenticated = authctxt->validTRUE | never evaluated | FALSE | never evaluated |
? 1 : 0; | 0 |
505 | break; never executed: break; | 0 |
506 | case never executed: case 1: 1:never executed: case 1: | 0 |
507 | | - |
508 | if (send_userauth_info_request(ssh) == 1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
509 | authctxt->postponed = 1; never executed: authctxt->postponed = 1; | 0 |
510 | break; never executed: break; | 0 |
511 | default never executed: default: :never executed: default: | 0 |
512 | | - |
513 | break; never executed: break; | 0 |
514 | } | - |
515 | devicename = kbdintctxt->device->name; | - |
516 | if (!authctxt->postponedTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
517 | if (authenticatedTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
518 | auth2_challenge_stop(ssh); | - |
519 | } never executed: end of block else { | 0 |
520 | | - |
521 | | - |
522 | auth2_challenge_start(ssh); | - |
523 | } never executed: end of block | 0 |
524 | } | - |
525 | userauth_finish(ssh, authenticated, "keyboard-interactive", | - |
526 | devicename); | - |
527 | return never executed: return 0; 0;never executed: return 0; | 0 |
528 | } | - |
529 | | - |
530 | void | - |
531 | privsep_challenge_enable(void) | - |
532 | { | - |
533 | } | - |
| | |