Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | extern Options options; | - |
16 | | - |
17 | | - |
18 | extern int stdin_null_flag; | - |
19 | | - |
20 | | - |
21 | extern int no_shell_flag; | - |
22 | | - |
23 | | - |
24 | extern int fork_after_authentication_flag; | - |
25 | | - |
26 | | - |
27 | extern int muxserver_sock; | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | extern char *host; | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | | - |
41 | | - |
42 | static volatile sig_atomic_t received_window_change_signal = 0; | - |
43 | static volatile sig_atomic_t received_signal = 0; | - |
44 | | - |
45 | | - |
46 | static int in_non_blocking_mode = 0; | - |
47 | | - |
48 | | - |
49 | static time_t control_persist_exit_time = 0; | - |
50 | | - |
51 | | - |
52 | volatile sig_atomic_t quit_pending; | - |
53 | static int last_was_cr; | - |
54 | static int exit_status; | - |
55 | static struct sshbuf *stderr_buffer; | - |
56 | static int connection_in; | - |
57 | static int connection_out; | - |
58 | static int need_rekeying; | - |
59 | static int session_closed; | - |
60 | static u_int x11_refuse_time; | - |
61 | | - |
62 | static void client_init_dispatch(void); | - |
63 | int session_ident = -1; | - |
64 | | - |
65 | | - |
66 | struct escape_filter_ctx { | - |
67 | int escape_pending; | - |
68 | int escape_char; | - |
69 | }; | - |
70 | | - |
71 | | - |
72 | struct channel_reply_ctx { | - |
73 | const char *request_type; | - |
74 | int id; | - |
75 | enum confirm_action action; | - |
76 | }; | - |
77 | | - |
78 | | - |
79 | | - |
80 | struct global_confirm { | - |
81 | struct { struct global_confirm *tqe_next; struct global_confirm **tqe_prev; } entry; | - |
82 | global_confirm_cb *cb; | - |
83 | void *ctx; | - |
84 | int ref_count; | - |
85 | }; | - |
86 | struct global_confirms { struct global_confirm *tqh_first; struct global_confirm **tqh_last; }; | - |
87 | static struct global_confirms global_confirms = | - |
88 | { | - |
89 | ((void *)0) | - |
90 | , &(global_confirms).tqh_first }; | - |
91 | | - |
92 | void ssh_process_session2_setup(int, int, int, struct sshbuf *); | - |
93 | | - |
94 | | - |
95 | | - |
96 | static void | - |
97 | leave_non_blocking(void) | - |
98 | { | - |
99 | if (in_non_blocking_modeTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
100 | unset_nonblock(fileno( | - |
101 | stdin | - |
102 | )); | - |
103 | in_non_blocking_mode = 0; | - |
104 | } never executed: end of block | 0 |
105 | } never executed: end of block | 0 |
106 | | - |
107 | | - |
108 | | - |
109 | | - |
110 | | - |
111 | | - |
112 | static void | - |
113 | window_change_handler(int sig) | - |
114 | { | - |
115 | received_window_change_signal = 1; | - |
116 | } never executed: end of block | 0 |
117 | | - |
118 | | - |
119 | | - |
120 | | - |
121 | | - |
122 | | - |
123 | static void | - |
124 | signal_handler(int sig) | - |
125 | { | - |
126 | received_signal = sig; | - |
127 | quit_pending = 1; | - |
128 | } never executed: end of block | 0 |
129 | | - |
130 | | - |
131 | | - |
132 | | - |
133 | | - |
134 | | - |
135 | | - |
136 | static void | - |
137 | set_control_persist_exit_time(struct ssh *ssh) | - |
138 | { | - |
139 | if (muxserver_sock == -1TRUE | never evaluated | FALSE | never evaluated |
|| !options.control_persistTRUE | never evaluated | FALSE | never evaluated |
| 0 |
140 | || options.control_persist_timeout == 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
141 | | - |
142 | control_persist_exit_time = 0; | - |
143 | } never executed: end of block else if (channel_still_open(ssh)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
144 | | - |
145 | if (control_persist_exit_time > 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
146 | debug2("%s: cancel scheduled exit", __func__); never executed: debug2("%s: cancel scheduled exit", __func__); | 0 |
147 | control_persist_exit_time = 0; | - |
148 | } never executed: end of block else if (control_persist_exit_time <= 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
149 | | - |
150 | control_persist_exit_time = monotime() + | - |
151 | (time_t)options.control_persist_timeout; | - |
152 | debug2("%s: schedule exit in %d seconds", __func__, | - |
153 | options.control_persist_timeout); | - |
154 | } never executed: end of block | 0 |
155 | | - |
156 | } never executed: end of block | 0 |
157 | | - |
158 | | - |
159 | static int | - |
160 | client_x11_display_valid(const char *display) | - |
161 | { | - |
162 | size_t i, dlen; | - |
163 | | - |
164 | if (display == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
165 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
166 | ) | - |
167 | return never executed: return 0; 0;never executed: return 0; | 0 |
168 | | - |
169 | dlen = strlen(display); | - |
170 | for (i = 0; i < dlenTRUE | never evaluated | FALSE | never evaluated |
; i++) { | 0 |
171 | if (!TRUE | never evaluated | FALSE | never evaluated |
| 0 |
172 | ((*__ctype_b_loc ())[(int) ((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
173 | (u_char)display[i]TRUE | never evaluated | FALSE | never evaluated |
| 0 |
174 | ))] & (unsigned short int) _ISalnum)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
175 | && | - |
176 | | - |
177 | (TRUE | never evaluated | FALSE | never evaluated |
__extension__ (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
178 | display[i]TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
179 | )TRUE | never evaluated | FALSE | never evaluated |
&& !__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
180 | ":/.-_"TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
181 | )TRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
182 | display[i]TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
183 | ) == '\0'TRUE | never evaluated | FALSE | never evaluated |
? (char *) __rawmemchr (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
184 | ":/.-_"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
185 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
186 | display[i]TRUE | never evaluated | FALSE | never evaluated |
| 0 |
187 | ) : __builtin_strchr (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
188 | ":/.-_"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
189 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
190 | display[i]TRUE | never evaluated | FALSE | never evaluated |
| 0 |
191 | ))) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
192 | == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
193 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
194 | ) { | - |
195 | debug("Invalid character '%c' in DISPLAY", display[i]); | - |
196 | return never executed: return 0; 0;never executed: return 0; | 0 |
197 | } | - |
198 | } never executed: end of block | 0 |
199 | return never executed: return 1; 1;never executed: return 1; | 0 |
200 | } | - |
201 | | - |
202 | | - |
203 | | - |
204 | int | - |
205 | client_x11_get_proto(struct ssh *ssh, const char *display, | - |
206 | const char *xauth_path, u_int trusted, u_int timeout, | - |
207 | char **_proto, char **_data) | - |
208 | { | - |
209 | char *cmd, line[512], xdisplay[512]; | - |
210 | char xauthfile[ | - |
211 | 4096 | - |
212 | ], xauthdir[ | - |
213 | 4096 | - |
214 | ]; | - |
215 | static char proto[512], data[512]; | - |
216 | FILE *f; | - |
217 | int got_data = 0, generated = 0, do_unlink = 0, r; | - |
218 | struct stat st; | - |
219 | u_int now, x11_timeout_real; | - |
220 | | - |
221 | *_proto = proto; | - |
222 | *_data = data; | - |
223 | proto[0] = data[0] = xauthfile[0] = xauthdir[0] = '\0'; | - |
224 | | - |
225 | if (!client_x11_display_valid(display)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
226 | if (display != TRUE | never evaluated | FALSE | never evaluated |
| 0 |
227 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
228 | ) | - |
229 | logit("DISPLAY \"%s\" invalid; disabling X11 forwarding", never executed: logit("DISPLAY \"%s\" invalid; disabling X11 forwarding", display); | 0 |
230 | display); never executed: logit("DISPLAY \"%s\" invalid; disabling X11 forwarding", display); | 0 |
231 | return never executed: return -1; -1;never executed: return -1; | 0 |
232 | } | - |
233 | if (xauth_path != TRUE | never evaluated | FALSE | never evaluated |
| 0 |
234 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
235 | && stat(xauth_path, &st) == -1TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
236 | debug("No xauth program."); | - |
237 | xauth_path = | - |
238 | ((void *)0) | - |
239 | ; | - |
240 | } never executed: end of block | 0 |
241 | | - |
242 | if (xauth_path != TRUE | never evaluated | FALSE | never evaluated |
| 0 |
243 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
244 | ) { | - |
245 | | - |
246 | | - |
247 | | - |
248 | | - |
249 | | - |
250 | | - |
251 | | - |
252 | if ( | - |
253 | (TRUE | never evaluated | FALSE | never evaluated |
__extension__ (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
254 | 10TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
255 | )TRUE | never evaluated | FALSE | never evaluated |
&& ((__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
256 | displayTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
257 | )TRUE | never evaluated | FALSE | never evaluated |
&& strlen (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
258 | displayTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
259 | ) < ((size_t) (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
260 | 10TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
261 | ))TRUE | never evaluated | FALSE | never evaluated |
) || (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
262 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
263 | )TRUE | never evaluated | FALSE | never evaluated |
&& strlen (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
264 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
265 | ) < ((size_t) (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
266 | 10TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
267 | ))TRUE | never evaluated | FALSE | never evaluated |
)) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
268 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
269 | ) && __builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
270 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
271 | ) && (__s1_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
272 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
273 | ), __s2_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
274 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
275 | ), (!((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
276 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
277 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
278 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
279 | ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
280 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
281 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
282 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
283 | ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
284 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
285 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
286 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
287 | ) : (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
288 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
289 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
290 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
291 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
292 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
293 | ) == 1) && (__s1_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
294 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
295 | ), __s1_len < 4) ? (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
296 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
297 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
298 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
299 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
300 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
301 | ) == 1) ? __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
302 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
303 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
304 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
305 | ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
306 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
307 | ); int __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
308 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
309 | ))[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 |
310 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
311 | ))[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 |
312 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
313 | ))[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 *) ( display ))[3] - __s2[3]); | 0 |
314 | displayTRUE | never evaluated | FALSE | never evaluated |
never executed: __result = (((const unsigned char *) (const char *) ( display ))[3] - __s2[3]); | 0 |
315 | ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
316 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
317 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
318 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
319 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
320 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
321 | ) == 1) && (__s2_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
322 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
323 | ), __s2_len < 4) ? (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
324 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
325 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
326 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
327 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
328 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
329 | ) == 1) ? __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
330 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
331 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
332 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
333 | ) : -(__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
334 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
335 | ); int __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
336 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
337 | ))[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 |
338 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
339 | ))[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 |
340 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
341 | ))[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 *) ( "localhost:" ))[3] - __s2[3]); | 0 |
342 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
never executed: __result = (((const unsigned char *) (const char *) ( "localhost:" ))[3] - __s2[3]); | 0 |
343 | ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
344 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
345 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
346 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
347 | )))); }) : strncmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
348 | displayTRUE | never evaluated | FALSE | never evaluated |
| 0 |
349 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
350 | "localhost:"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
351 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
352 | 10TRUE | never evaluated | FALSE | never evaluated |
| 0 |
353 | ))) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
354 | == 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
355 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = snprintf(xdisplay, sizeof(xdisplay), "unix:%s",TRUE | never evaluated | FALSE | never evaluated |
| 0 |
356 | display + 10)) < 0TRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
357 | (TRUE | never evaluated | FALSE | never evaluated |
size_t)r >= sizeof(xdisplay)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
358 | error("%s: display name too long", __func__); | - |
359 | return never executed: return -1; -1;never executed: return -1; | 0 |
360 | } | - |
361 | display = xdisplay; | - |
362 | } never executed: end of block | 0 |
363 | if (trusted == 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
364 | | - |
365 | | - |
366 | | - |
367 | | - |
368 | | - |
369 | | - |
370 | | - |
371 | mktemp_proto(xauthdir, sizeof(xauthdir)); | - |
372 | if (mkdtemp(xauthdir) == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
373 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
374 | ) { | - |
375 | error("%s: mkdtemp: %s", | - |
376 | __func__, strerror( | - |
377 | (*__errno_location ()) | - |
378 | )); | - |
379 | return never executed: return -1; -1;never executed: return -1; | 0 |
380 | } | - |
381 | do_unlink = 1; | - |
382 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = snprintf(xauthfile, sizeof(xauthfile),TRUE | never evaluated | FALSE | never evaluated |
| 0 |
383 | "%s/xauthfile", xauthdir)) < 0TRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
384 | (TRUE | never evaluated | FALSE | never evaluated |
size_t)r >= sizeof(xauthfile)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
385 | error("%s: xauthfile path too long", __func__); | - |
386 | unlink(xauthfile); | - |
387 | rmdir(xauthdir); | - |
388 | return never executed: return -1; -1;never executed: return -1; | 0 |
389 | } | - |
390 | | - |
391 | if (timeout == 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
392 | | - |
393 | xasprintf(&cmd, "%s -f %s generate %s %s " | - |
394 | "untrusted 2>%s", | - |
395 | xauth_path, xauthfile, display, | - |
396 | "MIT-MAGIC-COOKIE-1", | - |
397 | "/dev/null" | - |
398 | ); | - |
399 | } never executed: end of block else { | 0 |
400 | | - |
401 | if (timeout < TRUE | never evaluated | FALSE | never evaluated |
| 0 |
402 | (0x7fffffff * 2U + 1U) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
403 | - 60TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
404 | x11_timeout_real = timeout + never executed: x11_timeout_real = timeout + 60; | 0 |
405 | 60; never executed: x11_timeout_real = timeout + 60; | 0 |
406 | else { | - |
407 | | - |
408 | x11_timeout_real = | - |
409 | (0x7fffffff * 2U + 1U) | - |
410 | ; | - |
411 | } never executed: end of block | 0 |
412 | xasprintf(&cmd, "%s -f %s generate %s %s " | - |
413 | "untrusted timeout %u 2>%s", | - |
414 | xauth_path, xauthfile, display, | - |
415 | "MIT-MAGIC-COOKIE-1", x11_timeout_real, | - |
416 | | - |
417 | "/dev/null" | - |
418 | ); | - |
419 | } never executed: end of block | 0 |
420 | debug2("%s: %s", __func__, cmd); | - |
421 | | - |
422 | if (timeout != 0TRUE | never evaluated | FALSE | never evaluated |
&& x11_refuse_time == 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
423 | now = monotime() + 1; | - |
424 | if ( | - |
425 | (TRUE | never evaluated | FALSE | never evaluated |
0x7fffffff * 2U + 1U) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
426 | - timeout < nowTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
427 | x11_refuse_time = never executed: x11_refuse_time = (0x7fffffff * 2U + 1U) ; | 0 |
428 | (0x7fffffff * 2U + 1U) never executed: x11_refuse_time = (0x7fffffff * 2U + 1U) ; | 0 |
429 | ; never executed: x11_refuse_time = (0x7fffffff * 2U + 1U) ; | 0 |
430 | else | - |
431 | x11_refuse_time = now + timeout; never executed: x11_refuse_time = now + timeout; | 0 |
432 | channel_set_x11_refuse_time(ssh, | - |
433 | x11_refuse_time); | - |
434 | } never executed: end of block | 0 |
435 | if (system(cmd) == 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
436 | generated = 1; never executed: generated = 1; | 0 |
437 | free(cmd); | - |
438 | } never executed: end of block | 0 |
439 | | - |
440 | | - |
441 | | - |
442 | | - |
443 | | - |
444 | | - |
445 | if (trustedTRUE | never evaluated | FALSE | never evaluated |
|| generatedTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
446 | xasprintf(&cmd, | - |
447 | "%s %s%s list %s 2>" | - |
448 | "/dev/null" | - |
449 | , | - |
450 | xauth_path, | - |
451 | generated ? "-f " : "" , | - |
452 | generated ? xauthfile : "", | - |
453 | display); | - |
454 | debug2("x11_get_proto: %s", cmd); | - |
455 | f = popen(cmd, "r"); | - |
456 | if (fTRUE | never evaluated | FALSE | never evaluated |
&& fgets(line, sizeof(line), f)TRUE | never evaluated | FALSE | never evaluated |
&& | 0 |
457 | sscanf(line, "%*s %511s %511s", proto, data) == 2TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
458 | got_data = 1; never executed: got_data = 1; | 0 |
459 | if (fTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
460 | pclose(f); never executed: pclose(f); | 0 |
461 | free(cmd); | - |
462 | } never executed: end of block | 0 |
463 | } never executed: end of block | 0 |
464 | | - |
465 | if (do_unlinkTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
466 | unlink(xauthfile); | - |
467 | rmdir(xauthdir); | - |
468 | } never executed: end of block | 0 |
469 | | - |
470 | | - |
471 | if (!trustedTRUE | never evaluated | FALSE | never evaluated |
&& !got_dataTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
472 | error("Warning: untrusted X11 forwarding setup failed: " | - |
473 | "xauth key data not generated"); | - |
474 | return never executed: return -1; -1;never executed: return -1; | 0 |
475 | } | - |
476 | if (!got_dataTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
477 | u_int8_t rnd[16]; | - |
478 | u_int i; | - |
479 | | - |
480 | logit("Warning: No xauth data; " | - |
481 | "using fake authentication data for X11 forwarding."); | - |
482 | strlcpy(proto, "MIT-MAGIC-COOKIE-1", sizeof proto); | - |
483 | arc4random_buf(rnd, sizeof(rnd)); | - |
484 | for (i = 0; i < sizeof(rnd)TRUE | never evaluated | FALSE | never evaluated |
; i++) { | 0 |
485 | snprintf(data + 2 * i, sizeof data - 2 * i, "%02x", | - |
486 | rnd[i]); | - |
487 | } never executed: end of block | 0 |
488 | } never executed: end of block | 0 |
489 | | - |
490 | return never executed: return 0; 0;never executed: return 0; | 0 |
491 | } | - |
492 | static void | - |
493 | client_check_window_change(struct ssh *ssh) | - |
494 | { | - |
495 | if (!received_window_change_signalTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
496 | return; never executed: return; | 0 |
497 | | - |
498 | received_window_change_signal = 0; | - |
499 | | - |
500 | debug2("%s: changed", __func__); | - |
501 | | - |
502 | channel_send_window_changes(ssh); | - |
503 | } never executed: end of block | 0 |
504 | | - |
505 | static int | - |
506 | client_global_request_reply(int type, u_int32_t seq, struct ssh *ssh) | - |
507 | { | - |
508 | struct global_confirm *gc; | - |
509 | | - |
510 | if ((TRUE | never evaluated | FALSE | never evaluated |
gc = ((&global_confirms)->tqh_first)) == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
511 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
512 | ) | - |
513 | return never executed: return 0; 0;never executed: return 0; | 0 |
514 | if (gc->cb != TRUE | never evaluated | FALSE | never evaluated |
| 0 |
515 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
516 | ) | - |
517 | gc->cb(ssh, type, seq, gc->ctx); never executed: gc->cb(ssh, type, seq, gc->ctx); | 0 |
518 | if (--TRUE | never evaluated | FALSE | never evaluated |
gc->ref_count <= 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
519 | do { if (((TRUE | never evaluated | FALSE | never evaluated |
gc)->entry.tqe_next) != TRUE | never evaluated | FALSE | never evaluated |
| 0 |
520 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
521 | ) ( never executed: (gc)->entry.tqe_next->entry.tqe_prev = (gc)->entry.tqe_prev; gc)->entry.tqe_next->entry.tqe_prev = (gc)->entry.tqe_prev;never executed: (gc)->entry.tqe_next->entry.tqe_prev = (gc)->entry.tqe_prev; else (never executed: (&global_confirms)->tqh_last = (gc)->entry.tqe_prev; &global_confirms)->tqh_last = (gc)->entry.tqe_prev;never executed: (&global_confirms)->tqh_last = (gc)->entry.tqe_prev; *(gc)->entry.tqe_prev = (gc)->entry.tqe_next; ; ; } while (0); | 0 |
522 | explicit_bzero(gc, sizeof(*gc)); | - |
523 | free(gc); | - |
524 | } never executed: end of block | 0 |
525 | | - |
526 | ssh_packet_set_alive_timeouts(active_state, (0)); | - |
527 | return never executed: return 0; 0;never executed: return 0; | 0 |
528 | } | - |
529 | | - |
530 | static void | - |
531 | server_alive_check(void) | - |
532 | { | - |
533 | if (ssh_packet_inc_alive_timeouts(active_state) > options.server_alive_count_maxTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
534 | logit("Timeout, server %s not responding.", host); | - |
535 | cleanup_exit(255); | - |
536 | } never executed: end of block | 0 |
537 | ssh_packet_start(active_state, (80)); | - |
538 | ssh_packet_put_cstring(active_state, ("keepalive@openssh.com")); | - |
539 | ssh_packet_put_char(active_state, (1)); | - |
540 | ssh_packet_send(active_state); | - |
541 | | - |
542 | client_register_global_confirm( | - |
543 | ((void *)0) | - |
544 | , | - |
545 | ((void *)0) | - |
546 | ); | - |
547 | } never executed: end of block | 0 |
548 | | - |
549 | | - |
550 | | - |
551 | | - |
552 | | - |
553 | static void | - |
554 | client_wait_until_can_do_something(struct ssh *ssh, | - |
555 | fd_set **readsetp, fd_set **writesetp, | - |
556 | int *maxfdp, u_int *nallocp, int rekeying) | - |
557 | { | - |
558 | struct timeval tv, *tvp; | - |
559 | int timeout_secs; | - |
560 | time_t minwait_secs = 0, server_alive_time = 0, now = monotime(); | - |
561 | int r, ret; | - |
562 | | - |
563 | | - |
564 | channel_prepare_select(active_state, readsetp, writesetp, maxfdp, | - |
565 | nallocp, &minwait_secs); | - |
566 | | - |
567 | | - |
568 | if (session_closedTRUE | never evaluated | FALSE | never evaluated |
&& !channel_still_open(ssh)TRUE | never evaluated | FALSE | never evaluated |
&& | 0 |
569 | !ssh_packet_have_data_to_write(active_state)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
570 | | - |
571 | memset(*readsetp, 0, *nallocp); | - |
572 | memset(*writesetp, 0, *nallocp); | - |
573 | return; never executed: return; | 0 |
574 | } | - |
575 | | - |
576 | kludge_FD_SET(connection_in, *readsetp); | - |
577 | | - |
578 | | - |
579 | if (ssh_packet_have_data_to_write(active_state)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
580 | kludge_FD_SET(connection_out, *writesetp); never executed: kludge_FD_SET(connection_out, *writesetp); | 0 |
581 | | - |
582 | | - |
583 | | - |
584 | | - |
585 | | - |
586 | | - |
587 | | - |
588 | timeout_secs = 0x7fffffff; | - |
589 | if (options.server_alive_interval > 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
590 | timeout_secs = options.server_alive_interval; | - |
591 | server_alive_time = now + options.server_alive_interval; | - |
592 | } never executed: end of block | 0 |
593 | if (options.rekey_interval > 0TRUE | never evaluated | FALSE | never evaluated |
&& !rekeyingTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
594 | timeout_secs = (((TRUE | never evaluated | FALSE | never evaluated |
timeout_secs) < (ssh_packet_get_rekey_timeout(active_state)))TRUE | never evaluated | FALSE | never evaluated |
? (timeout_secs) : (ssh_packet_get_rekey_timeout(active_state)));never executed: timeout_secs = (((timeout_secs) < (ssh_packet_get_rekey_timeout(active_state))) ? (timeout_secs) : (ssh_packet_get_rekey_timeout(active_state))); | 0 |
595 | set_control_persist_exit_time(ssh); | - |
596 | if (control_persist_exit_time > 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
597 | timeout_secs = (((TRUE | never evaluated | FALSE | never evaluated |
timeout_secs) < (control_persist_exit_time - now))TRUE | never evaluated | FALSE | never evaluated |
? (timeout_secs) : (control_persist_exit_time - now)) | 0 |
598 | ; | - |
599 | if (timeout_secs < 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
600 | timeout_secs = 0; never executed: timeout_secs = 0; | 0 |
601 | } never executed: end of block | 0 |
602 | if (minwait_secs != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
603 | timeout_secs = (((TRUE | never evaluated | FALSE | never evaluated |
timeout_secs) < ((int)minwait_secs))TRUE | never evaluated | FALSE | never evaluated |
? (timeout_secs) : ((int)minwait_secs));never executed: timeout_secs = (((timeout_secs) < ((int)minwait_secs)) ? (timeout_secs) : ((int)minwait_secs)); | 0 |
604 | if (timeout_secs == 0x7fffffffTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
605 | tvp = never executed: tvp = ((void *)0) ; | 0 |
606 | ((void *)0) never executed: tvp = ((void *)0) ; | 0 |
607 | ; never executed: tvp = ((void *)0) ; | 0 |
608 | else { | - |
609 | tv.tv_sec = timeout_secs; | - |
610 | tv.tv_usec = 0; | - |
611 | tvp = &tv; | - |
612 | } never executed: end of block | 0 |
613 | | - |
614 | ret = select((*maxfdp)+1, *readsetp, *writesetp, | - |
615 | ((void *)0) | - |
616 | , tvp); | - |
617 | if (ret < 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
618 | | - |
619 | | - |
620 | | - |
621 | | - |
622 | | - |
623 | memset(*readsetp, 0, *nallocp); | - |
624 | memset(*writesetp, 0, *nallocp); | - |
625 | | - |
626 | if ( | - |
627 | (*TRUE | never evaluated | FALSE | never evaluated |
__errno_location ()) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
628 | == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
629 | 4TRUE | never evaluated | FALSE | never evaluated |
| 0 |
630 | ) | - |
631 | return; never executed: return; | 0 |
632 | | - |
633 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_putf(stderr_buffer,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
634 | "select: %s\r\n", strerror(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
635 | (*__errno_location ())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
636 | ))) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
637 | fatal("%s: buffer error: %s", __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
638 | quit_pending = 1; | - |
639 | } never executed: end of block else if (ret == 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
640 | | - |
641 | | - |
642 | | - |
643 | | - |
644 | if (server_alive_time != 0TRUE | never evaluated | FALSE | never evaluated |
&& server_alive_time <= monotime()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
645 | server_alive_check(); never executed: server_alive_check(); | 0 |
646 | } never executed: end of block | 0 |
647 | | - |
648 | } never executed: end of block | 0 |
649 | | - |
650 | static void | - |
651 | client_suspend_self(struct sshbuf *bin, struct sshbuf *bout, struct sshbuf *berr) | - |
652 | { | - |
653 | | - |
654 | if (sshbuf_len(bout) > 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
655 | atomicio((ssize_t (*)(int, void *, size_t))write, fileno( never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stdout ), sshbuf_mutable_ptr(bout), sshbuf_len(bout)); | 0 |
656 | stdout never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stdout ), sshbuf_mutable_ptr(bout), sshbuf_len(bout)); | 0 |
657 | ), sshbuf_mutable_ptr(bout), never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stdout ), sshbuf_mutable_ptr(bout), sshbuf_len(bout)); | 0 |
658 | sshbuf_len(bout)); never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stdout ), sshbuf_mutable_ptr(bout), sshbuf_len(bout)); | 0 |
659 | if (sshbuf_len(berr) > 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
660 | atomicio((ssize_t (*)(int, void *, size_t))write, fileno( never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stderr ), sshbuf_mutable_ptr(berr), sshbuf_len(berr)); | 0 |
661 | stderr never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stderr ), sshbuf_mutable_ptr(berr), sshbuf_len(berr)); | 0 |
662 | ), sshbuf_mutable_ptr(berr), never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stderr ), sshbuf_mutable_ptr(berr), sshbuf_len(berr)); | 0 |
663 | sshbuf_len(berr)); never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stderr ), sshbuf_mutable_ptr(berr), sshbuf_len(berr)); | 0 |
664 | | - |
665 | leave_raw_mode(options.request_tty == 3); | - |
666 | | - |
667 | sshbuf_reset(bin); | - |
668 | sshbuf_reset(bout); | - |
669 | sshbuf_reset(berr); | - |
670 | | - |
671 | | - |
672 | kill(getpid(), | - |
673 | 20 | - |
674 | ); | - |
675 | | - |
676 | | - |
677 | received_window_change_signal = 1; | - |
678 | | - |
679 | enter_raw_mode(options.request_tty == 3); | - |
680 | } never executed: end of block | 0 |
681 | | - |
682 | static void | - |
683 | client_process_net_input(fd_set *readset) | - |
684 | { | - |
685 | char buf[8192]; | - |
686 | int r, len; | - |
687 | | - |
688 | | - |
689 | | - |
690 | | - |
691 | | - |
692 | if (kludge_FD_ISSET(connection_in, readset)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
693 | | - |
694 | len = read(connection_in, buf, sizeof(buf)); | - |
695 | if (len == 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
696 | | - |
697 | | - |
698 | | - |
699 | | - |
700 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_putf(stderr_buffer,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
701 | "Connection to %.300s closed by remote host.\r\n",TRUE | never evaluated | FALSE | never evaluated |
| 0 |
702 | host)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
703 | fatal("%s: buffer error: %s", never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
704 | __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
705 | quit_pending = 1; | - |
706 | return; never executed: return; | 0 |
707 | } | - |
708 | | - |
709 | | - |
710 | | - |
711 | | - |
712 | if (len < 0TRUE | never evaluated | FALSE | never evaluated |
&& | 0 |
713 | ( | - |
714 | (*TRUE | never evaluated | FALSE | never evaluated |
__errno_location ()) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
715 | == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
716 | 11TRUE | never evaluated | FALSE | never evaluated |
| 0 |
717 | || | - |
718 | (*TRUE | never evaluated | FALSE | never evaluated |
__errno_location ()) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
719 | == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
720 | 4TRUE | never evaluated | FALSE | never evaluated |
| 0 |
721 | || | - |
722 | (*TRUE | never evaluated | FALSE | never evaluated |
__errno_location ()) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
723 | == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
724 | 11TRUE | never evaluated | FALSE | never evaluated |
| 0 |
725 | )) | - |
726 | len = 0; never executed: len = 0; | 0 |
727 | | - |
728 | if (len < 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
729 | | - |
730 | | - |
731 | | - |
732 | | - |
733 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_putf(stderr_buffer,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
734 | "Read from remote host %.300s: %.100s\r\n",TRUE | never evaluated | FALSE | never evaluated |
| 0 |
735 | host, strerror(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
736 | (*__errno_location ())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
737 | ))) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
738 | fatal("%s: buffer error: %s", never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
739 | __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
740 | quit_pending = 1; | - |
741 | return; never executed: return; | 0 |
742 | } | - |
743 | packet_process_incoming(buf, len); | - |
744 | } never executed: end of block | 0 |
745 | } never executed: end of block | 0 |
746 | | - |
747 | static void | - |
748 | client_status_confirm(struct ssh *ssh, int type, Channel *c, void *ctx) | - |
749 | { | - |
750 | struct channel_reply_ctx *cr = (struct channel_reply_ctx *)ctx; | - |
751 | char errmsg[256]; | - |
752 | int r, tochan; | - |
753 | | - |
754 | | - |
755 | | - |
756 | | - |
757 | | - |
758 | if (cr->action == CONFIRM_TTYTRUE | never evaluated | FALSE | never evaluated |
&& | 0 |
759 | (options.request_tty == 3TRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
760 | options.request_tty == 2TRUE | never evaluated | FALSE | never evaluated |
)) | 0 |
761 | cr->action = CONFIRM_CLOSE; never executed: cr->action = CONFIRM_CLOSE; | 0 |
762 | | - |
763 | | - |
764 | tochan = options.log_level >= SYSLOG_LEVEL_ERRORTRUE | never evaluated | FALSE | never evaluated |
&& | 0 |
765 | c->ctl_chan != -1TRUE | never evaluated | FALSE | never evaluated |
&& c->extended_usage == 2TRUE | never evaluated | FALSE | never evaluated |
; | 0 |
766 | | - |
767 | if (type == 99TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
768 | debug2("%s request accepted on channel %d", | - |
769 | cr->request_type, c->self); | - |
770 | } never executed: end of block else if (type == 100TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
771 | if (tochanTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
772 | snprintf(errmsg, sizeof(errmsg), | - |
773 | "%s request failed\r\n", cr->request_type); | - |
774 | } never executed: end of block else { | 0 |
775 | snprintf(errmsg, sizeof(errmsg), | - |
776 | "%s request failed on channel %d", | - |
777 | cr->request_type, c->self); | - |
778 | } never executed: end of block | 0 |
779 | | - |
780 | if (cr->action == CONFIRM_CLOSETRUE | never evaluated | FALSE | never evaluated |
&& c->self == session_identTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
781 | fatal("%s", errmsg); never executed: fatal("%s", errmsg); | 0 |
782 | | - |
783 | | - |
784 | | - |
785 | | - |
786 | if (tochanTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
787 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_put(c->extended, errmsg,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
788 | strlen(errmsg))) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
789 | fatal("%s: buffer error %s", __func__, never executed: fatal("%s: buffer error %s", __func__, ssh_err(r)); | 0 |
790 | ssh_err(r)); never executed: fatal("%s: buffer error %s", __func__, ssh_err(r)); | 0 |
791 | } never executed: end of block else | 0 |
792 | error("%s", errmsg); never executed: error("%s", errmsg); | 0 |
793 | if (cr->action == CONFIRM_TTYTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
794 | | - |
795 | | - |
796 | | - |
797 | | - |
798 | if (c->self == session_identTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
799 | leave_raw_mode(0); never executed: leave_raw_mode(0); | 0 |
800 | else | - |
801 | mux_tty_alloc_failed(ssh, c); never executed: mux_tty_alloc_failed(ssh, c); | 0 |
802 | } else if (cr->action == CONFIRM_CLOSETRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
803 | chan_read_failed(ssh, c); | - |
804 | chan_write_failed(ssh, c); | - |
805 | } never executed: end of block | 0 |
806 | } never executed: end of block | 0 |
807 | free(cr); | - |
808 | } never executed: end of block | 0 |
809 | | - |
810 | static void | - |
811 | client_abandon_status_confirm(struct ssh *ssh, Channel *c, void *ctx) | - |
812 | { | - |
813 | free(ctx); | - |
814 | } never executed: end of block | 0 |
815 | | - |
816 | void | - |
817 | client_expect_confirm(struct ssh *ssh, int id, const char *request, | - |
818 | enum confirm_action action) | - |
819 | { | - |
820 | struct channel_reply_ctx *cr = xcalloc(1, sizeof(*cr)); | - |
821 | | - |
822 | cr->request_type = request; | - |
823 | cr->action = action; | - |
824 | | - |
825 | channel_register_status_confirm(ssh, id, client_status_confirm, | - |
826 | client_abandon_status_confirm, cr); | - |
827 | } never executed: end of block | 0 |
828 | | - |
829 | void | - |
830 | client_register_global_confirm(global_confirm_cb *cb, void *ctx) | - |
831 | { | - |
832 | struct global_confirm *gc, *last_gc; | - |
833 | | - |
834 | | - |
835 | last_gc = (*(((struct global_confirms *)((&global_confirms)->tqh_last))->tqh_last)); | - |
836 | if (last_gcTRUE | never evaluated | FALSE | never evaluated |
&& last_gc->cb == cbTRUE | never evaluated | FALSE | never evaluated |
&& last_gc->ctx == ctxTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
837 | if (++TRUE | never evaluated | FALSE | never evaluated |
last_gc->ref_count >= 0x7fffffffTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
838 | fatal("%s: last_gc->ref_count = %d", never executed: fatal("%s: last_gc->ref_count = %d", __func__, last_gc->ref_count); | 0 |
839 | __func__, last_gc->ref_count); never executed: fatal("%s: last_gc->ref_count = %d", __func__, last_gc->ref_count); | 0 |
840 | return; never executed: return; | 0 |
841 | } | - |
842 | | - |
843 | gc = xcalloc(1, sizeof(*gc)); | - |
844 | gc->cb = cb; | - |
845 | gc->ctx = ctx; | - |
846 | gc->ref_count = 1; | - |
847 | do { (gc)->entry.tqe_next = | - |
848 | ((void *)0) | - |
849 | ; (gc)->entry.tqe_prev = (&global_confirms)->tqh_last; *(&global_confirms)->tqh_last = (gc); (&global_confirms)->tqh_last = &(gc)->entry.tqe_next; } while (0); | - |
850 | } never executed: end of block | 0 |
851 | | - |
852 | static void | - |
853 | process_cmdline(struct ssh *ssh) | - |
854 | { | - |
855 | void (*handler)(int); | - |
856 | char *s, *cmd; | - |
857 | int ok, delete = 0, local = 0, remote = 0, dynamic = 0; | - |
858 | struct Forward fwd; | - |
859 | | - |
860 | memset(&fwd, 0, sizeof(fwd)); | - |
861 | | - |
862 | leave_raw_mode(options.request_tty == 3); | - |
863 | handler = mysignal( | - |
864 | 2 | - |
865 | , | - |
866 | ((__sighandler_t) 1) | - |
867 | ); | - |
868 | cmd = s = read_passphrase("\r\nssh> ", 0x0001); | - |
869 | if (s == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
870 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
871 | ) | - |
872 | goto never executed: goto out; out;never executed: goto out; | 0 |
873 | while ( | - |
874 | ((*TRUE | never evaluated | FALSE | never evaluated |
__ctype_b_loc ())[(int) ((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
875 | (u_char)*sTRUE | never evaluated | FALSE | never evaluated |
| 0 |
876 | ))] & (unsigned short int) _ISspace)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
877 | ) | - |
878 | s++; never executed: s++; | 0 |
879 | if (*TRUE | never evaluated | FALSE | never evaluated |
s == '-'TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
880 | s++; never executed: s++; | 0 |
881 | if (*TRUE | never evaluated | FALSE | never evaluated |
s == '\0'TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
882 | goto never executed: goto out; out;never executed: goto out; | 0 |
883 | | - |
884 | if (*TRUE | never evaluated | FALSE | never evaluated |
s == 'h'TRUE | never evaluated | FALSE | never evaluated |
|| *TRUE | never evaluated | FALSE | never evaluated |
s == 'H'TRUE | never evaluated | FALSE | never evaluated |
|| *TRUE | never evaluated | FALSE | never evaluated |
s == '?'TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
885 | logit("Commands:"); | - |
886 | logit(" -L[bind_address:]port:host:hostport " | - |
887 | "Request local forward"); | - |
888 | logit(" -R[bind_address:]port:host:hostport " | - |
889 | "Request remote forward"); | - |
890 | logit(" -D[bind_address:]port " | - |
891 | "Request dynamic forward"); | - |
892 | logit(" -KL[bind_address:]port " | - |
893 | "Cancel local forward"); | - |
894 | logit(" -KR[bind_address:]port " | - |
895 | "Cancel remote forward"); | - |
896 | logit(" -KD[bind_address:]port " | - |
897 | "Cancel dynamic forward"); | - |
898 | if (!options.permit_local_commandTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
899 | goto never executed: goto out; out;never executed: goto out; | 0 |
900 | logit(" !args " | - |
901 | "Execute local command"); | - |
902 | goto never executed: goto out; out;never executed: goto out; | 0 |
903 | } | - |
904 | | - |
905 | if (*TRUE | never evaluated | FALSE | never evaluated |
s == '!'TRUE | never evaluated | FALSE | never evaluated |
&& options.permit_local_commandTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
906 | s++; | - |
907 | ssh_local_cmd(s); | - |
908 | goto never executed: goto out; out;never executed: goto out; | 0 |
909 | } | - |
910 | | - |
911 | if (*TRUE | never evaluated | FALSE | never evaluated |
s == 'K'TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
912 | delete = 1; | - |
913 | s++; | - |
914 | } never executed: end of block | 0 |
915 | if (*TRUE | never evaluated | FALSE | never evaluated |
s == 'L'TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
916 | local = 1; never executed: local = 1; | 0 |
917 | else if (*TRUE | never evaluated | FALSE | never evaluated |
s == 'R'TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
918 | remote = 1; never executed: remote = 1; | 0 |
919 | else if (*TRUE | never evaluated | FALSE | never evaluated |
s == 'D'TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
920 | dynamic = 1; never executed: dynamic = 1; | 0 |
921 | else { | - |
922 | logit("Invalid command."); | - |
923 | goto never executed: goto out; out;never executed: goto out; | 0 |
924 | } | - |
925 | | - |
926 | while ( | - |
927 | ((*TRUE | never evaluated | FALSE | never evaluated |
__ctype_b_loc ())[(int) ((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
928 | (u_char)*++sTRUE | never evaluated | FALSE | never evaluated |
| 0 |
929 | ))] & (unsigned short int) _ISspace)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
930 | ) | - |
931 | ; never executed: ; | 0 |
932 | | - |
933 | | - |
934 | if (deleteTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
935 | | - |
936 | if (!parse_forward(&fwd, s, 1, 0)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
937 | logit("Bad forwarding close specification."); | - |
938 | goto never executed: goto out; out;never executed: goto out; | 0 |
939 | } | - |
940 | if (remoteTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
941 | ok = channel_request_rforward_cancel(ssh, &fwd) == 0; never executed: ok = channel_request_rforward_cancel(ssh, &fwd) == 0; | 0 |
942 | else if (dynamicTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
943 | ok = channel_cancel_lport_listener(ssh, &fwd, never executed: ok = channel_cancel_lport_listener(ssh, &fwd, 0, &options.fwd_opts) > 0; | 0 |
944 | 0, &options.fwd_opts) > 0; never executed: ok = channel_cancel_lport_listener(ssh, &fwd, 0, &options.fwd_opts) > 0; | 0 |
945 | else | - |
946 | ok = channel_cancel_lport_listener(ssh, &fwd, never executed: ok = channel_cancel_lport_listener(ssh, &fwd, -1, &options.fwd_opts) > 0; | 0 |
947 | -1, never executed: ok = channel_cancel_lport_listener(ssh, &fwd, -1, &options.fwd_opts) > 0; | 0 |
948 | &options.fwd_opts) > 0; never executed: ok = channel_cancel_lport_listener(ssh, &fwd, -1, &options.fwd_opts) > 0; | 0 |
949 | if (!okTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
950 | logit("Unknown port forwarding."); | - |
951 | goto never executed: goto out; out;never executed: goto out; | 0 |
952 | } | - |
953 | logit("Canceled forwarding."); | - |
954 | } never executed: end of block else { | 0 |
955 | if (!parse_forward(&fwd, s, dynamic, remote)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
956 | logit("Bad forwarding specification."); | - |
957 | goto never executed: goto out; out;never executed: goto out; | 0 |
958 | } | - |
959 | if (localTRUE | never evaluated | FALSE | never evaluated |
|| dynamicTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
960 | if (!channel_setup_local_fwd_listener(ssh, &fwd,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
961 | &options.fwd_opts)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
962 | logit("Port forwarding failed."); | - |
963 | goto never executed: goto out; out;never executed: goto out; | 0 |
964 | } | - |
965 | } never executed: end of block else { | 0 |
966 | if (channel_request_remote_forwarding(ssh, &fwd) < 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
967 | logit("Port forwarding failed."); | - |
968 | goto never executed: goto out; out;never executed: goto out; | 0 |
969 | } | - |
970 | } never executed: end of block | 0 |
971 | logit("Forwarding port."); | - |
972 | } never executed: end of block | 0 |
973 | | - |
974 | out: code before this statement never executed: out: | 0 |
975 | mysignal( | - |
976 | 2 | - |
977 | ,handler); | - |
978 | enter_raw_mode(options.request_tty == 3); | - |
979 | free(cmd); | - |
980 | free(fwd.listen_host); | - |
981 | free(fwd.listen_path); | - |
982 | free(fwd.connect_host); | - |
983 | free(fwd.connect_path); | - |
984 | } never executed: end of block | 0 |
985 | | - |
986 | | - |
987 | | - |
988 | | - |
989 | | - |
990 | | - |
991 | struct escape_help_text { | - |
992 | const char *cmd; | - |
993 | const char *text; | - |
994 | unsigned int flags; | - |
995 | }; | - |
996 | static struct escape_help_text esc_txt[] = { | - |
997 | {".", "terminate session", 2}, | - |
998 | {".", "terminate connection (and any multiplexed sessions)", | - |
999 | 1}, | - |
1000 | {"B", "send a BREAK to the remote system", 0}, | - |
1001 | {"C", "open a command line", 1}, | - |
1002 | {"R", "request rekey", 0}, | - |
1003 | {"V/v", "decrease/increase verbosity (LogLevel)", 1}, | - |
1004 | {"^Z", "suspend ssh", 1}, | - |
1005 | {"#", "list forwarded connections", 0}, | - |
1006 | {"&", "background ssh (when waiting for connections to terminate)", | - |
1007 | 1}, | - |
1008 | {"?", "this message", 0}, | - |
1009 | }; | - |
1010 | | - |
1011 | static void | - |
1012 | print_escape_help(struct sshbuf *b, int escape_char, int mux_client, | - |
1013 | int using_stderr) | - |
1014 | { | - |
1015 | unsigned int i, suppress_flags; | - |
1016 | int r; | - |
1017 | | - |
1018 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_putf(b,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1019 | "%c?\r\nSupported escape sequences:\r\n", escape_char)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1020 | fatal("%s: buffer error: %s", __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1021 | | - |
1022 | suppress_flags = | - |
1023 | (mux_clientTRUE | never evaluated | FALSE | never evaluated |
? 1 : 0) | | 0 |
1024 | (mux_client ? 0 : 2) | | - |
1025 | (using_stderr ? 0 : 4); | - |
1026 | | - |
1027 | for (i = 0; i < sizeof(esc_txt)/sizeof(esc_txt[0])TRUE | never evaluated | FALSE | never evaluated |
; i++) { | 0 |
1028 | if (esc_txt[i].flags & suppress_flagsTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1029 | continue; never executed: continue; | 0 |
1030 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_putf(b, " %c%-3s - %s\r\n",TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1031 | escape_char, esc_txt[i].cmd, esc_txt[i].text)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1032 | fatal("%s: buffer error: %s", __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1033 | } never executed: end of block | 0 |
1034 | | - |
1035 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_putf(b,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1036 | " %c%c - send the escape character by typing it twice\r\n"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1037 | "(Note that escapes are only recognized immediately after "TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1038 | "newline.)\r\n", escape_char, escape_char)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1039 | fatal("%s: buffer error: %s", __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1040 | } never executed: end of block | 0 |
1041 | | - |
1042 | | - |
1043 | | - |
1044 | | - |
1045 | static int | - |
1046 | process_escapes(struct ssh *ssh, Channel *c, | - |
1047 | struct sshbuf *bin, struct sshbuf *bout, struct sshbuf *berr, | - |
1048 | char *buf, int len) | - |
1049 | { | - |
1050 | pid_t pid; | - |
1051 | int r, bytes = 0; | - |
1052 | u_int i; | - |
1053 | u_char ch; | - |
1054 | char *s; | - |
1055 | struct escape_filter_ctx *efc = c->filter_ctx == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1056 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1057 | ? | - |
1058 | | - |
1059 | ((void *)0) | - |
1060 | : (struct escape_filter_ctx *)c->filter_ctx; | - |
1061 | | - |
1062 | if (c->filter_ctx == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1063 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1064 | ) | - |
1065 | return never executed: return 0; 0;never executed: return 0; | 0 |
1066 | | - |
1067 | if (len <= 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1068 | return never executed: return (0); (0);never executed: return (0); | 0 |
1069 | | - |
1070 | for (i = 0; i < (u_int)lenTRUE | never evaluated | FALSE | never evaluated |
; i++) { | 0 |
1071 | | - |
1072 | ch = buf[i]; | - |
1073 | | - |
1074 | if (efc->escape_pendingTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1075 | | - |
1076 | | - |
1077 | efc->escape_pending = 0; | - |
1078 | | - |
1079 | | - |
1080 | switch (ch) { | - |
1081 | case never executed: case '.': '.':never executed: case '.': | 0 |
1082 | | - |
1083 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_putf(berr, "%c.\r\n",TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1084 | efc->escape_char)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1085 | fatal("%s: buffer error: %s", never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1086 | __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1087 | if (cTRUE | never evaluated | FALSE | never evaluated |
&& c->ctl_chan != -1TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1088 | chan_read_failed(ssh, c); | - |
1089 | chan_write_failed(ssh, c); | - |
1090 | if (c->detach_userTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1091 | c->detach_user(ssh, | - |
1092 | c->self, | - |
1093 | ((void *)0) | - |
1094 | ); | - |
1095 | } never executed: end of block | 0 |
1096 | c->type = 17; | - |
1097 | sshbuf_reset(c->input); | - |
1098 | chan_ibuf_empty(ssh, c); | - |
1099 | return never executed: return 0; 0;never executed: return 0; | 0 |
1100 | } else | - |
1101 | quit_pending = 1; never executed: quit_pending = 1; | 0 |
1102 | return never executed: return -1; -1;never executed: return -1; | 0 |
1103 | | - |
1104 | case never executed: case 'Z' - 64: 'Z' - 64:never executed: case 'Z' - 64: | 0 |
1105 | | - |
1106 | if (cTRUE | never evaluated | FALSE | never evaluated |
&& c->ctl_chan != -1TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1107 | char b[16]; | - |
1108 | noescape: code before this statement never executed: noescape: | 0 |
1109 | if (ch == 'Z' - 64TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1110 | snprintf(b, sizeof b, "^Z"); never executed: snprintf(b, sizeof b, "^Z"); | 0 |
1111 | else | - |
1112 | snprintf(b, sizeof b, "%c", ch); never executed: snprintf(b, sizeof b, "%c", ch); | 0 |
1113 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_putf(berr,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1114 | "%c%s escape not available to "TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1115 | "multiplexed sessions\r\n",TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1116 | efc->escape_char, b)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1117 | fatal("%s: buffer error: %s", never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1118 | __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1119 | continue; never executed: continue; | 0 |
1120 | } | - |
1121 | | - |
1122 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_putf(berr,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1123 | "%c^Z [suspend ssh]\r\n",TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1124 | efc->escape_char)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1125 | fatal("%s: buffer error: %s", never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1126 | __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1127 | | - |
1128 | | - |
1129 | client_suspend_self(bin, bout, berr); | - |
1130 | | - |
1131 | | - |
1132 | continue; never executed: continue; | 0 |
1133 | | - |
1134 | case never executed: case 'B': 'B':never executed: case 'B': | 0 |
1135 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_putf(berr,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1136 | "%cB\r\n", efc->escape_char)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1137 | fatal("%s: buffer error: %s", never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1138 | __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1139 | channel_request_start(ssh, c->self, "break", 0); | - |
1140 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshpkt_put_u32(ssh, 1000)) != 0TRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
1141 | (TRUE | never evaluated | FALSE | never evaluated |
r = sshpkt_send(ssh)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1142 | fatal("%s: %s", __func__, never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 |
1143 | ssh_err(r)); never executed: fatal("%s: %s", __func__, ssh_err(r)); | 0 |
1144 | continue; never executed: continue; | 0 |
1145 | | - |
1146 | case never executed: case 'R': 'R':never executed: case 'R': | 0 |
1147 | if (datafellows & 0x00008000TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1148 | logit("Server does not " never executed: logit("Server does not " "support re-keying"); | 0 |
1149 | "support re-keying"); never executed: logit("Server does not " "support re-keying"); | 0 |
1150 | else | - |
1151 | need_rekeying = 1; never executed: need_rekeying = 1; | 0 |
1152 | continue; never executed: continue; | 0 |
1153 | | - |
1154 | case never executed: case 'V': 'V':never executed: case 'V': | 0 |
1155 | | - |
1156 | case never executed: case 'v': 'v':never executed: case 'v': | 0 |
1157 | if (cTRUE | never evaluated | FALSE | never evaluated |
&& c->ctl_chan != -1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1158 | goto never executed: goto noescape; noescape;never executed: goto noescape; | 0 |
1159 | if (!log_is_on_stderr()TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1160 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_putf(berr,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1161 | "%c%c [Logging to syslog]\r\n",TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1162 | efc->escape_char, ch)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1163 | fatal("%s: buffer error: %s", never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1164 | __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1165 | continue; never executed: continue; | 0 |
1166 | } | - |
1167 | if (ch == 'V'TRUE | never evaluated | FALSE | never evaluated |
&& options.log_level >TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1168 | SYSLOG_LEVEL_QUIETTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1169 | log_change_level(--options.log_level); never executed: log_change_level(--options.log_level); | 0 |
1170 | if (ch == 'v'TRUE | never evaluated | FALSE | never evaluated |
&& options.log_level <TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1171 | SYSLOG_LEVEL_DEBUG3TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1172 | log_change_level(++options.log_level); never executed: log_change_level(++options.log_level); | 0 |
1173 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_putf(berr,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1174 | "%c%c [LogLevel %s]\r\n",TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1175 | efc->escape_char, ch,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1176 | log_level_name(options.log_level))) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1177 | fatal("%s: buffer error: %s", never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1178 | __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1179 | continue; never executed: continue; | 0 |
1180 | | - |
1181 | case never executed: case '&': '&':never executed: case '&': | 0 |
1182 | if (cTRUE | never evaluated | FALSE | never evaluated |
&& c->ctl_chan != -1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1183 | goto never executed: goto noescape; noescape;never executed: goto noescape; | 0 |
1184 | | - |
1185 | | - |
1186 | | - |
1187 | | - |
1188 | | - |
1189 | | - |
1190 | leave_raw_mode( | - |
1191 | options.request_tty == 3); | - |
1192 | | - |
1193 | | - |
1194 | channel_stop_listening(ssh); | - |
1195 | | - |
1196 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_putf(berr,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1197 | "%c& [backgrounded]\n", efc->escape_char))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1198 | != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1199 | fatal("%s: buffer error: %s", never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1200 | __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1201 | | - |
1202 | | - |
1203 | pid = fork(); | - |
1204 | if (pid < 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1205 | error("fork: %.100s", strerror( | - |
1206 | (*__errno_location ()) | - |
1207 | )); | - |
1208 | continue; never executed: continue; | 0 |
1209 | } | - |
1210 | if (pid != 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1211 | | - |
1212 | exit(0); never executed: exit(0); | 0 |
1213 | } | - |
1214 | | - |
1215 | | - |
1216 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_put_u8(bin, 4)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1217 | fatal("%s: buffer error: %s", never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1218 | __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1219 | return never executed: return -1; -1;never executed: return -1; | 0 |
1220 | case never executed: case '?': '?':never executed: case '?': | 0 |
1221 | print_escape_help(berr, efc->escape_char, | - |
1222 | (c && c->ctl_chan != -1), | - |
1223 | log_is_on_stderr()); | - |
1224 | continue; never executed: continue; | 0 |
1225 | | - |
1226 | case never executed: case '#': '#':never executed: case '#': | 0 |
1227 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_putf(berr, "%c#\r\n",TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1228 | efc->escape_char)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1229 | fatal("%s: buffer error: %s", never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1230 | __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1231 | s = channel_open_message(ssh); | - |
1232 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_put(berr, s, strlen(s))) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1233 | fatal("%s: buffer error: %s", never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1234 | __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1235 | free(s); | - |
1236 | continue; never executed: continue; | 0 |
1237 | | - |
1238 | case never executed: case 'C': 'C':never executed: case 'C': | 0 |
1239 | if (cTRUE | never evaluated | FALSE | never evaluated |
&& c->ctl_chan != -1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1240 | goto never executed: goto noescape; noescape;never executed: goto noescape; | 0 |
1241 | process_cmdline(ssh); | - |
1242 | continue; never executed: continue; | 0 |
1243 | | - |
1244 | default never executed: default: :never executed: default: | 0 |
1245 | if (ch != efc->escape_charTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1246 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_put_u8(bin,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1247 | efc->escape_char)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1248 | fatal("%s: buffer error: %s", never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1249 | __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1250 | bytes++; | - |
1251 | } never executed: end of block | 0 |
1252 | | - |
1253 | break; never executed: break; | 0 |
1254 | } | - |
1255 | } else { | - |
1256 | | - |
1257 | | - |
1258 | | - |
1259 | | - |
1260 | if (last_was_crTRUE | never evaluated | FALSE | never evaluated |
&& ch == efc->escape_charTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1261 | | - |
1262 | | - |
1263 | | - |
1264 | | - |
1265 | efc->escape_pending = 1; | - |
1266 | continue; never executed: continue; | 0 |
1267 | } | - |
1268 | } never executed: end of block | 0 |
1269 | | - |
1270 | | - |
1271 | | - |
1272 | | - |
1273 | | - |
1274 | last_was_cr = (ch == '\r'TRUE | never evaluated | FALSE | never evaluated |
|| ch == '\n'TRUE | never evaluated | FALSE | never evaluated |
); | 0 |
1275 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = sshbuf_put_u8(bin, ch)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1276 | fatal("%s: buffer error: %s", __func__, ssh_err(r)); never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 0 |
1277 | bytes++; | - |
1278 | } never executed: end of block | 0 |
1279 | return never executed: return bytes; bytes;never executed: return bytes; | 0 |
1280 | } | - |
1281 | static void | - |
1282 | client_process_buffered_input_packets(void) | - |
1283 | { | - |
1284 | ssh_dispatch_run_fatal(active_state, DISPATCH_NONBLOCK, &quit_pending); | - |
1285 | } never executed: end of block | 0 |
1286 | | - |
1287 | | - |
1288 | | - |
1289 | | - |
1290 | void * | - |
1291 | client_new_escape_filter_ctx(int escape_char) | - |
1292 | { | - |
1293 | struct escape_filter_ctx *ret; | - |
1294 | | - |
1295 | ret = xcalloc(1, sizeof(*ret)); | - |
1296 | ret->escape_pending = 0; | - |
1297 | ret->escape_char = escape_char; | - |
1298 | return never executed: return (void *)ret; (void *)ret;never executed: return (void *)ret; | 0 |
1299 | } | - |
1300 | | - |
1301 | | - |
1302 | void | - |
1303 | client_filter_cleanup(struct ssh *ssh, int cid, void *ctx) | - |
1304 | { | - |
1305 | free(ctx); | - |
1306 | } never executed: end of block | 0 |
1307 | | - |
1308 | int | - |
1309 | client_simple_escape_filter(struct ssh *ssh, Channel *c, char *buf, int len) | - |
1310 | { | - |
1311 | if (c->extended_usage != 2TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1312 | return never executed: return 0; 0;never executed: return 0; | 0 |
1313 | | - |
1314 | return never executed: return process_escapes(ssh, c, c->input, c->output, c->extended, buf, len); process_escapes(ssh, c, c->input, c->output, c->extended,never executed: return process_escapes(ssh, c, c->input, c->output, c->extended, buf, len); | 0 |
1315 | buf, len); never executed: return process_escapes(ssh, c, c->input, c->output, c->extended, buf, len); | 0 |
1316 | } | - |
1317 | | - |
1318 | static void | - |
1319 | client_channel_closed(struct ssh *ssh, int id, void *arg) | - |
1320 | { | - |
1321 | channel_cancel_cleanup(ssh, id); | - |
1322 | session_closed = 1; | - |
1323 | leave_raw_mode(options.request_tty == 3); | - |
1324 | } never executed: end of block | 0 |
1325 | | - |
1326 | | - |
1327 | | - |
1328 | | - |
1329 | | - |
1330 | | - |
1331 | | - |
1332 | int | - |
1333 | client_loop(struct ssh *ssh, int have_pty, int escape_char_arg, | - |
1334 | int ssh2_chan_id) | - |
1335 | { | - |
1336 | fd_set *readset = | - |
1337 | ((void *)0) | - |
1338 | , *writeset = | - |
1339 | ((void *)0) | - |
1340 | ; | - |
1341 | double start_time, total_time; | - |
1342 | int r, max_fd = 0, max_fd2 = 0, len; | - |
1343 | u_int64_t ibytes, obytes; | - |
1344 | u_int nalloc = 0; | - |
1345 | char buf[100]; | - |
1346 | | - |
1347 | debug("Entering interactive session."); | - |
1348 | | - |
1349 | if (options.control_masterTRUE | never evaluated | FALSE | never evaluated |
&& | 0 |
1350 | !option_clear_or_none(options.control_path)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1351 | debug("pledge: id"); | - |
1352 | if (pledge("stdio rpath wpath cpath unix inet dns recvfd proc exec id tty",TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1353 | TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1354 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1355 | ) == -1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1356 | fatal("%s pledge(): %s", __func__, strerror( never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) )); | 0 |
1357 | (*__errno_location ()) never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) )); | 0 |
1358 | )); never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) )); | 0 |
1359 | | - |
1360 | } never executed: end of block else if (options.forward_x11TRUE | never evaluated | FALSE | never evaluated |
|| options.permit_local_commandTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1361 | debug("pledge: exec"); | - |
1362 | if (pledge("stdio rpath wpath cpath unix inet dns proc exec tty",TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1363 | TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1364 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1365 | ) == -1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1366 | fatal("%s pledge(): %s", __func__, strerror( never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) )); | 0 |
1367 | (*__errno_location ()) never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) )); | 0 |
1368 | )); never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) )); | 0 |
1369 | | - |
1370 | } never executed: end of block else if (options.update_hostkeysTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1371 | debug("pledge: filesystem full"); | - |
1372 | if (pledge("stdio rpath wpath cpath unix inet dns proc tty",TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1373 | TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1374 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1375 | ) == -1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1376 | fatal("%s pledge(): %s", __func__, strerror( never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) )); | 0 |
1377 | (*__errno_location ()) never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) )); | 0 |
1378 | )); never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) )); | 0 |
1379 | | - |
1380 | } never executed: end of block else if (!option_clear_or_none(options.proxy_command)TRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
1381 | fork_after_authentication_flagTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1382 | debug("pledge: proc"); | - |
1383 | if (pledge("stdio cpath unix inet dns proc tty", TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1384 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1385 | ) == -1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1386 | fatal("%s pledge(): %s", __func__, strerror( never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) )); | 0 |
1387 | (*__errno_location ()) never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) )); | 0 |
1388 | )); never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) )); | 0 |
1389 | | - |
1390 | } never executed: end of block else { | 0 |
1391 | debug("pledge: network"); | - |
1392 | if (pledge("stdio unix inet dns proc tty", TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1393 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1394 | ) == -1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1395 | fatal("%s pledge(): %s", __func__, strerror( never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) )); | 0 |
1396 | (*__errno_location ()) never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) )); | 0 |
1397 | )); never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) )); | 0 |
1398 | } never executed: end of block | 0 |
1399 | | - |
1400 | start_time = monotime_double(); | - |
1401 | | - |
1402 | | - |
1403 | last_was_cr = 1; | - |
1404 | exit_status = -1; | - |
1405 | connection_in = ssh_packet_get_connection_in(active_state); | - |
1406 | connection_out = ssh_packet_get_connection_out(active_state); | - |
1407 | max_fd = (((TRUE | never evaluated | FALSE | never evaluated |
connection_in) > (connection_out))TRUE | never evaluated | FALSE | never evaluated |
? (connection_in) : (connection_out)); | 0 |
1408 | | - |
1409 | quit_pending = 0; | - |
1410 | | - |
1411 | | - |
1412 | if ((TRUE | never evaluated | FALSE | never evaluated |
stderr_buffer = sshbuf_new()) == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1413 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1414 | ) | - |
1415 | fatal("%s: sshbuf_new failed", __func__); never executed: fatal("%s: sshbuf_new failed", __func__); | 0 |
1416 | | - |
1417 | client_init_dispatch(); | - |
1418 | | - |
1419 | | - |
1420 | | - |
1421 | | - |
1422 | | - |
1423 | if (mysignal(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1424 | 1TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1425 | ,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1426 | ((__sighandler_t) 1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1427 | ) != TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1428 | ((__sighandler_t) 1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1429 | ) | - |
1430 | mysignal( never executed: mysignal( 1 ,signal_handler); | 0 |
1431 | 1 never executed: mysignal( 1 ,signal_handler); | 0 |
1432 | ,signal_handler); never executed: mysignal( 1 ,signal_handler); | 0 |
1433 | if (mysignal(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1434 | 2TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1435 | ,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1436 | ((__sighandler_t) 1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1437 | ) != TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1438 | ((__sighandler_t) 1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1439 | ) | - |
1440 | mysignal( never executed: mysignal( 2 ,signal_handler); | 0 |
1441 | 2 never executed: mysignal( 2 ,signal_handler); | 0 |
1442 | ,signal_handler); never executed: mysignal( 2 ,signal_handler); | 0 |
1443 | if (mysignal(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1444 | 3TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1445 | ,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1446 | ((__sighandler_t) 1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1447 | ) != TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1448 | ((__sighandler_t) 1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1449 | ) | - |
1450 | mysignal( never executed: mysignal( 3 ,signal_handler); | 0 |
1451 | 3 never executed: mysignal( 3 ,signal_handler); | 0 |
1452 | ,signal_handler); never executed: mysignal( 3 ,signal_handler); | 0 |
1453 | if (mysignal(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1454 | 15TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1455 | ,TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1456 | ((__sighandler_t) 1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1457 | ) != TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1458 | ((__sighandler_t) 1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1459 | ) | - |
1460 | mysignal( never executed: mysignal( 15 ,signal_handler); | 0 |
1461 | 15 never executed: mysignal( 15 ,signal_handler); | 0 |
1462 | ,signal_handler); never executed: mysignal( 15 ,signal_handler); | 0 |
1463 | mysignal( | - |
1464 | 28 | - |
1465 | ,window_change_handler); | - |
1466 | | - |
1467 | if (have_ptyTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1468 | enter_raw_mode(options.request_tty == 3); never executed: enter_raw_mode(options.request_tty == 3); | 0 |
1469 | | - |
1470 | session_ident = ssh2_chan_id; | - |
1471 | if (session_ident != -1TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1472 | if (escape_char_arg != -2TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1473 | channel_register_filter(ssh, session_ident, | - |
1474 | client_simple_escape_filter, | - |
1475 | ((void *)0) | - |
1476 | , | - |
1477 | client_filter_cleanup, | - |
1478 | client_new_escape_filter_ctx( | - |
1479 | escape_char_arg)); | - |
1480 | } never executed: end of block | 0 |
1481 | channel_register_cleanup(ssh, session_ident, | - |
1482 | client_channel_closed, 0); | - |
1483 | } never executed: end of block | 0 |
1484 | | - |
1485 | | - |
1486 | while (!quit_pendingTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1487 | | - |
1488 | | - |
1489 | client_process_buffered_input_packets(); | - |
1490 | | - |
1491 | if (session_closedTRUE | never evaluated | FALSE | never evaluated |
&& !channel_still_open(ssh)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1492 | break; never executed: break; | 0 |
1493 | | - |
1494 | if (ssh_packet_is_rekeying(ssh)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1495 | debug("rekeying in progress"); | - |
1496 | } never executed: end of block else if (need_rekeyingTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1497 | | - |
1498 | debug("need rekeying"); | - |
1499 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = kex_start_rekex(ssh)) != 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1500 | fatal("%s: kex_start_rekex: %s", __func__, never executed: fatal("%s: kex_start_rekex: %s", __func__, ssh_err(r)); | 0 |
1501 | ssh_err(r)); never executed: fatal("%s: kex_start_rekex: %s", __func__, ssh_err(r)); | 0 |
1502 | need_rekeying = 0; | - |
1503 | } never executed: end of block else { | 0 |
1504 | | - |
1505 | | - |
1506 | | - |
1507 | | - |
1508 | if (ssh_packet_not_very_much_data_to_write(active_state)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1509 | channel_output_poll(ssh); never executed: channel_output_poll(ssh); | 0 |
1510 | | - |
1511 | | - |
1512 | | - |
1513 | | - |
1514 | | - |
1515 | client_check_window_change(ssh); | - |
1516 | | - |
1517 | if (quit_pendingTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1518 | break; never executed: break; | 0 |
1519 | } never executed: end of block | 0 |
1520 | | - |
1521 | | - |
1522 | | - |
1523 | | - |
1524 | max_fd2 = max_fd; | - |
1525 | client_wait_until_can_do_something(ssh, &readset, &writeset, | - |
1526 | &max_fd2, &nalloc, ssh_packet_is_rekeying(ssh)); | - |
1527 | | - |
1528 | if (quit_pendingTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1529 | break; never executed: break; | 0 |
1530 | | - |
1531 | | - |
1532 | if (!ssh_packet_is_rekeying(ssh)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1533 | channel_after_select(ssh, readset, writeset); never executed: channel_after_select(ssh, readset, writeset); | 0 |
1534 | | - |
1535 | | - |
1536 | client_process_net_input(readset); | - |
1537 | | - |
1538 | if (quit_pendingTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1539 | break; never executed: break; | 0 |
1540 | | - |
1541 | | - |
1542 | | - |
1543 | | - |
1544 | | - |
1545 | if (kludge_FD_ISSET(connection_out, writeset)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1546 | packet_write_poll(); never executed: packet_write_poll(); | 0 |
1547 | | - |
1548 | | - |
1549 | | - |
1550 | | - |
1551 | | - |
1552 | | - |
1553 | if (control_persist_exit_time > 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1554 | if (monotime() >= control_persist_exit_timeTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1555 | debug("ControlPersist timeout expired"); | - |
1556 | break; never executed: break; | 0 |
1557 | } | - |
1558 | } never executed: end of block | 0 |
1559 | } never executed: end of block | 0 |
1560 | free(readset); | - |
1561 | free(writeset); | - |
1562 | | - |
1563 | | - |
1564 | | - |
1565 | | - |
1566 | mysignal( | - |
1567 | 28 | - |
1568 | , | - |
1569 | ((__sighandler_t) 0) | - |
1570 | ); | - |
1571 | | - |
1572 | ssh_packet_start(active_state, (1)); | - |
1573 | ssh_packet_put_int(active_state, (11)); | - |
1574 | ssh_packet_put_cstring(active_state, ("disconnected by user")); | - |
1575 | ssh_packet_put_cstring(active_state, ("")); | - |
1576 | ssh_packet_send(active_state); | - |
1577 | packet_write_wait(); | - |
1578 | | - |
1579 | channel_free_all(ssh); | - |
1580 | | - |
1581 | if (have_ptyTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1582 | leave_raw_mode(options.request_tty == 3); never executed: leave_raw_mode(options.request_tty == 3); | 0 |
1583 | | - |
1584 | | - |
1585 | if (!isatty(fileno(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1586 | stdinTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1587 | ))TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1588 | unset_nonblock(fileno( never executed: unset_nonblock(fileno( stdin )); | 0 |
1589 | stdin never executed: unset_nonblock(fileno( stdin )); | 0 |
1590 | )); never executed: unset_nonblock(fileno( stdin )); | 0 |
1591 | if (!isatty(fileno(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1592 | stdoutTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1593 | ))TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1594 | unset_nonblock(fileno( never executed: unset_nonblock(fileno( stdout )); | 0 |
1595 | stdout never executed: unset_nonblock(fileno( stdout )); | 0 |
1596 | )); never executed: unset_nonblock(fileno( stdout )); | 0 |
1597 | if (!isatty(fileno(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1598 | stderrTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1599 | ))TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1600 | unset_nonblock(fileno( never executed: unset_nonblock(fileno( stderr )); | 0 |
1601 | stderr never executed: unset_nonblock(fileno( stderr )); | 0 |
1602 | )); never executed: unset_nonblock(fileno( stderr )); | 0 |
1603 | | - |
1604 | | - |
1605 | | - |
1606 | | - |
1607 | | - |
1608 | | - |
1609 | if (no_shell_flagTRUE | never evaluated | FALSE | never evaluated |
&& received_signal == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1610 | 15TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1611 | ) { | - |
|