Mercurial > dropbear
comparison cli-chansession.c @ 108:10f4d3319780
- added circular buffering for channels
- added stderr support for the client
- cleaned up a bunch of "unused" warnings, duplicated header definitions
- added exit-status support for the client
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 26 Aug 2004 13:16:40 +0000 |
parents | d3eb1fa8484e |
children | 2e9d1f29c50f |
comparison
equal
deleted
inserted
replaced
107:d3eb1fa8484e | 108:10f4d3319780 |
---|---|
30 #include "dbutil.h" | 30 #include "dbutil.h" |
31 #include "channel.h" | 31 #include "channel.h" |
32 #include "ssh.h" | 32 #include "ssh.h" |
33 #include "runopts.h" | 33 #include "runopts.h" |
34 #include "termcodes.h" | 34 #include "termcodes.h" |
35 #include "chansession.h" | |
35 | 36 |
36 static void cli_closechansess(struct Channel *channel); | 37 static void cli_closechansess(struct Channel *channel); |
37 static int cli_initchansess(struct Channel *channel); | 38 static int cli_initchansess(struct Channel *channel); |
39 static void cli_chansessreq(struct Channel *channel); | |
38 | 40 |
39 static void start_channel_request(struct Channel *channel, unsigned char *type); | 41 static void start_channel_request(struct Channel *channel, unsigned char *type); |
40 | 42 |
41 static void send_chansess_pty_req(struct Channel *channel); | 43 static void send_chansess_pty_req(struct Channel *channel); |
42 static void send_chansess_shell_req(struct Channel *channel); | 44 static void send_chansess_shell_req(struct Channel *channel); |
43 | 45 |
44 static void cli_tty_setup(); | 46 static void cli_tty_setup(); |
45 void cli_tty_cleanup(); | |
46 | 47 |
47 const struct ChanType clichansess = { | 48 const struct ChanType clichansess = { |
48 0, /* sepfds */ | 49 0, /* sepfds */ |
49 "session", /* name */ | 50 "session", /* name */ |
50 cli_initchansess, /* inithandler */ | 51 cli_initchansess, /* inithandler */ |
51 NULL, /* checkclosehandler */ | 52 NULL, /* checkclosehandler */ |
52 NULL, /* reqhandler */ | 53 cli_chansessreq, /* reqhandler */ |
53 cli_closechansess, /* closehandler */ | 54 cli_closechansess, /* closehandler */ |
54 }; | 55 }; |
55 | 56 |
57 static void cli_chansessreq(struct Channel *channel) { | |
58 | |
59 unsigned char* type = NULL; | |
60 int wantreply; | |
61 | |
62 TRACE(("enter cli_chansessreq")); | |
63 | |
64 type = buf_getstring(ses.payload, NULL); | |
65 wantreply = buf_getbyte(ses.payload); | |
66 | |
67 if (strcmp(type, "exit-status") != 0) { | |
68 TRACE(("unknown request '%s'", type)); | |
69 send_msg_channel_failure(channel); | |
70 goto out; | |
71 } | |
72 | |
73 /* We'll just trust what they tell us */ | |
74 cli_ses.retval = buf_getint(ses.payload); | |
75 TRACE(("got exit-status of '%d'", cli_ses.retval)); | |
76 | |
77 out: | |
78 m_free(type); | |
79 } | |
80 | |
81 | |
56 /* If the main session goes, we close it up */ | 82 /* If the main session goes, we close it up */ |
57 static void cli_closechansess(struct Channel *channel) { | 83 static void cli_closechansess(struct Channel *UNUSED(channel)) { |
58 | 84 |
59 /* This channel hasn't gone yet, so we have > 1 */ | 85 /* This channel hasn't gone yet, so we have > 1 */ |
60 if (ses.chancount > 1) { | 86 if (ses.chancount > 1) { |
61 dropbear_log(LOG_INFO, "Waiting for other channels to close..."); | 87 dropbear_log(LOG_INFO, "Waiting for other channels to close..."); |
62 } | 88 } |
226 buf_putint(ses.writepayload, ws.ws_xpixel); /* Width */ | 252 buf_putint(ses.writepayload, ws.ws_xpixel); /* Width */ |
227 buf_putint(ses.writepayload, ws.ws_ypixel); /* Height */ | 253 buf_putint(ses.writepayload, ws.ws_ypixel); /* Height */ |
228 | 254 |
229 } | 255 } |
230 | 256 |
231 static void sigwinch_handler(int dummy) { | 257 static void sigwinch_handler(int UNUSED(unused)) { |
232 | 258 |
233 cli_ses.winchange = 1; | 259 cli_ses.winchange = 1; |
234 | 260 |
235 } | 261 } |
236 | 262 |
315 | 341 |
316 | 342 |
317 channel->infd = STDOUT_FILENO; | 343 channel->infd = STDOUT_FILENO; |
318 channel->outfd = STDIN_FILENO; | 344 channel->outfd = STDIN_FILENO; |
319 channel->errfd = STDERR_FILENO; | 345 channel->errfd = STDERR_FILENO; |
320 channel->extrabuf = buf_new(RECV_MAXWINDOW); | 346 channel->extrabuf = cbuf_new(RECV_MAXWINDOW); |
321 | 347 |
322 if (cli_opts.wantpty) { | 348 if (cli_opts.wantpty) { |
323 send_chansess_pty_req(channel); | 349 send_chansess_pty_req(channel); |
324 } | 350 } |
325 | 351 |