Mercurial > dropbear
comparison cli-chansession.c @ 165:0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 02 Jan 2005 20:25:56 +0000 |
parents | 2e9d1f29c50f |
children | 161557a9dde8 |
comparison
equal
deleted
inserted
replaced
161:b9d3f725e00b | 165:0cfba3034be5 |
---|---|
57 static void cli_chansessreq(struct Channel *channel) { | 57 static void cli_chansessreq(struct Channel *channel) { |
58 | 58 |
59 unsigned char* type = NULL; | 59 unsigned char* type = NULL; |
60 int wantreply; | 60 int wantreply; |
61 | 61 |
62 TRACE(("enter cli_chansessreq")); | 62 TRACE(("enter cli_chansessreq")) |
63 | 63 |
64 type = buf_getstring(ses.payload, NULL); | 64 type = buf_getstring(ses.payload, NULL); |
65 wantreply = buf_getbyte(ses.payload); | 65 wantreply = buf_getbyte(ses.payload); |
66 | 66 |
67 if (strcmp(type, "exit-status") != 0) { | 67 if (strcmp(type, "exit-status") != 0) { |
68 TRACE(("unknown request '%s'", type)); | 68 TRACE(("unknown request '%s'", type)) |
69 send_msg_channel_failure(channel); | 69 send_msg_channel_failure(channel); |
70 goto out; | 70 goto out; |
71 } | 71 } |
72 | 72 |
73 /* We'll just trust what they tell us */ | 73 /* We'll just trust what they tell us */ |
74 cli_ses.retval = buf_getint(ses.payload); | 74 cli_ses.retval = buf_getint(ses.payload); |
75 TRACE(("got exit-status of '%d'", cli_ses.retval)); | 75 TRACE(("got exit-status of '%d'", cli_ses.retval)) |
76 | 76 |
77 out: | 77 out: |
78 m_free(type); | 78 m_free(type); |
79 } | 79 } |
80 | 80 |
106 * RCSID("OpenBSD: sshtty.c,v 1.5 2003/09/19 17:43:35 markus Exp "); */ | 106 * RCSID("OpenBSD: sshtty.c,v 1.5 2003/09/19 17:43:35 markus Exp "); */ |
107 static void cli_tty_setup() { | 107 static void cli_tty_setup() { |
108 | 108 |
109 struct termios tio; | 109 struct termios tio; |
110 | 110 |
111 TRACE(("enter cli_pty_setup")); | 111 TRACE(("enter cli_pty_setup")) |
112 | 112 |
113 if (cli_ses.tty_raw_mode == 1) { | 113 if (cli_ses.tty_raw_mode == 1) { |
114 TRACE(("leave cli_tty_setup: already in raw mode!")); | 114 TRACE(("leave cli_tty_setup: already in raw mode!")) |
115 return; | 115 return; |
116 } | 116 } |
117 | 117 |
118 if (tcgetattr(STDIN_FILENO, &tio) == -1) { | 118 if (tcgetattr(STDIN_FILENO, &tio) == -1) { |
119 dropbear_exit("Failed to set raw TTY mode"); | 119 dropbear_exit("Failed to set raw TTY mode"); |
137 if (tcsetattr(STDIN_FILENO, TCSADRAIN, &tio) == -1) { | 137 if (tcsetattr(STDIN_FILENO, TCSADRAIN, &tio) == -1) { |
138 dropbear_exit("Failed to set raw TTY mode"); | 138 dropbear_exit("Failed to set raw TTY mode"); |
139 } | 139 } |
140 | 140 |
141 cli_ses.tty_raw_mode = 1; | 141 cli_ses.tty_raw_mode = 1; |
142 TRACE(("leave cli_tty_setup")); | 142 TRACE(("leave cli_tty_setup")) |
143 } | 143 } |
144 | 144 |
145 void cli_tty_cleanup() { | 145 void cli_tty_cleanup() { |
146 | 146 |
147 TRACE(("enter cli_tty_cleanup")); | 147 TRACE(("enter cli_tty_cleanup")) |
148 | 148 |
149 if (cli_ses.tty_raw_mode == 0) { | 149 if (cli_ses.tty_raw_mode == 0) { |
150 TRACE(("leave cli_tty_cleanup: not in raw mode")); | 150 TRACE(("leave cli_tty_cleanup: not in raw mode")) |
151 return; | 151 return; |
152 } | 152 } |
153 | 153 |
154 if (tcsetattr(STDIN_FILENO, TCSADRAIN, &cli_ses.saved_tio) == -1) { | 154 if (tcsetattr(STDIN_FILENO, TCSADRAIN, &cli_ses.saved_tio) == -1) { |
155 dropbear_log(LOG_WARNING, "Failed restoring TTY"); | 155 dropbear_log(LOG_WARNING, "Failed restoring TTY"); |
156 } else { | 156 } else { |
157 cli_ses.tty_raw_mode = 0; | 157 cli_ses.tty_raw_mode = 0; |
158 } | 158 } |
159 | 159 |
160 TRACE(("leave cli_tty_cleanup")); | 160 TRACE(("leave cli_tty_cleanup")) |
161 } | 161 } |
162 | 162 |
163 static void put_termcodes() { | 163 static void put_termcodes() { |
164 | 164 |
165 TRACE(("enter put_termcodes")); | 165 TRACE(("enter put_termcodes")) |
166 | 166 |
167 struct termios tio; | 167 struct termios tio; |
168 unsigned int sshcode; | 168 unsigned int sshcode; |
169 const struct TermCode *termcode; | 169 const struct TermCode *termcode; |
170 unsigned int value; | 170 unsigned int value; |
230 | 230 |
231 buf_setpos(ses.writepayload, bufpos1); /* Jump back */ | 231 buf_setpos(ses.writepayload, bufpos1); /* Jump back */ |
232 buf_putint(ses.writepayload, bufpos2 - bufpos1 - 4); /* len(termcodes) */ | 232 buf_putint(ses.writepayload, bufpos2 - bufpos1 - 4); /* len(termcodes) */ |
233 buf_setpos(ses.writepayload, bufpos2); /* Back where we were */ | 233 buf_setpos(ses.writepayload, bufpos2); /* Back where we were */ |
234 | 234 |
235 TRACE(("leave put_termcodes")); | 235 TRACE(("leave put_termcodes")) |
236 } | 236 } |
237 | 237 |
238 static void put_winsize() { | 238 static void put_winsize() { |
239 | 239 |
240 struct winsize ws; | 240 struct winsize ws; |
282 | 282 |
283 static void send_chansess_pty_req(struct Channel *channel) { | 283 static void send_chansess_pty_req(struct Channel *channel) { |
284 | 284 |
285 unsigned char* term = NULL; | 285 unsigned char* term = NULL; |
286 | 286 |
287 TRACE(("enter send_chansess_pty_req")); | 287 TRACE(("enter send_chansess_pty_req")) |
288 | 288 |
289 start_channel_request(channel, "pty-req"); | 289 start_channel_request(channel, "pty-req"); |
290 | 290 |
291 /* Don't want replies */ | 291 /* Don't want replies */ |
292 buf_putbyte(ses.writepayload, 0); | 292 buf_putbyte(ses.writepayload, 0); |
308 | 308 |
309 /* Set up a window-change handler */ | 309 /* Set up a window-change handler */ |
310 if (signal(SIGWINCH, sigwinch_handler) == SIG_ERR) { | 310 if (signal(SIGWINCH, sigwinch_handler) == SIG_ERR) { |
311 dropbear_exit("signal error"); | 311 dropbear_exit("signal error"); |
312 } | 312 } |
313 TRACE(("leave send_chansess_pty_req")); | 313 TRACE(("leave send_chansess_pty_req")) |
314 } | 314 } |
315 | 315 |
316 static void send_chansess_shell_req(struct Channel *channel) { | 316 static void send_chansess_shell_req(struct Channel *channel) { |
317 | 317 |
318 unsigned char* reqtype = NULL; | 318 unsigned char* reqtype = NULL; |
319 | 319 |
320 TRACE(("enter send_chansess_shell_req")); | 320 TRACE(("enter send_chansess_shell_req")) |
321 | 321 |
322 if (cli_opts.cmd) { | 322 if (cli_opts.cmd) { |
323 reqtype = "exec"; | 323 reqtype = "exec"; |
324 } else { | 324 } else { |
325 reqtype = "shell"; | 325 reqtype = "shell"; |
332 if (cli_opts.cmd) { | 332 if (cli_opts.cmd) { |
333 buf_putstring(ses.writepayload, cli_opts.cmd, strlen(cli_opts.cmd)); | 333 buf_putstring(ses.writepayload, cli_opts.cmd, strlen(cli_opts.cmd)); |
334 } | 334 } |
335 | 335 |
336 encrypt_packet(); | 336 encrypt_packet(); |
337 TRACE(("leave send_chansess_shell_req")); | 337 TRACE(("leave send_chansess_shell_req")) |
338 } | 338 } |
339 | 339 |
340 static int cli_initchansess(struct Channel *channel) { | 340 static int cli_initchansess(struct Channel *channel) { |
341 | 341 |
342 | 342 |
365 | 365 |
366 } | 366 } |
367 | 367 |
368 void cli_send_chansess_request() { | 368 void cli_send_chansess_request() { |
369 | 369 |
370 TRACE(("enter cli_send_chansess_request")); | 370 TRACE(("enter cli_send_chansess_request")) |
371 if (send_msg_channel_open_init(STDIN_FILENO, &clichansess) | 371 if (send_msg_channel_open_init(STDIN_FILENO, &clichansess) |
372 == DROPBEAR_FAILURE) { | 372 == DROPBEAR_FAILURE) { |
373 dropbear_exit("Couldn't open initial channel"); | 373 dropbear_exit("Couldn't open initial channel"); |
374 } | 374 } |
375 | 375 |
376 /* No special channel request data */ | 376 /* No special channel request data */ |
377 encrypt_packet(); | 377 encrypt_packet(); |
378 TRACE(("leave cli_send_chansess_request")); | 378 TRACE(("leave cli_send_chansess_request")) |
379 | 379 |
380 } | 380 } |