Mercurial > dropbear
comparison cli-main.c @ 479:e3db1f7a2e43
- Split main socket var into ses.sock_in/ses.sock_out in preparation
for -J proxy_cmd option (and some prelim options for that)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 15 Sep 2008 12:51:50 +0000 |
parents | 1afa503e33f5 |
children | 738313e73b1c |
comparison
equal
deleted
inserted
replaced
477:657c045054ab | 479:e3db1f7a2e43 |
---|---|
37 int cli_main(int argc, char ** argv) { | 37 int cli_main(int argc, char ** argv) { |
38 #else | 38 #else |
39 int main(int argc, char ** argv) { | 39 int main(int argc, char ** argv) { |
40 #endif | 40 #endif |
41 | 41 |
42 int sock; | 42 int sock_in, sock_out; |
43 char* error = NULL; | 43 char* error = NULL; |
44 char* hostandport; | 44 char* hostandport; |
45 int len; | 45 int len; |
46 | 46 |
47 _dropbear_exit = cli_dropbear_exit; | 47 _dropbear_exit = cli_dropbear_exit; |
56 | 56 |
57 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { | 57 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { |
58 dropbear_exit("signal() error"); | 58 dropbear_exit("signal() error"); |
59 } | 59 } |
60 | 60 |
61 sock = connect_remote(cli_opts.remotehost, cli_opts.remoteport, | 61 #ifdef CLI_ENABLE_PROXYCMD |
62 0, &error); | 62 if (cli_runopts.proxycmd) { |
63 | 63 |
64 if (sock < 0) { | 64 } else |
65 #endif | |
66 { | |
67 int sock = connect_remote(cli_opts.remotehost, cli_opts.remoteport, | |
68 0, &error); | |
69 sock_in = sock_out = sock; | |
70 } | |
71 | |
72 if (sock_in < 0) { | |
65 dropbear_exit("%s", error); | 73 dropbear_exit("%s", error); |
66 } | 74 } |
67 | 75 |
68 /* Set up the host:port log */ | 76 /* Set up the host:port log */ |
69 len = strlen(cli_opts.remotehost); | 77 len = strlen(cli_opts.remotehost); |
70 len += 10; /* 16 bit port and leeway*/ | 78 len += 10; /* 16 bit port and leeway*/ |
71 hostandport = (char*)m_malloc(len); | 79 hostandport = (char*)m_malloc(len); |
72 snprintf(hostandport, len, "%s:%s", | 80 snprintf(hostandport, len, "%s:%s", |
73 cli_opts.remotehost, cli_opts.remoteport); | 81 cli_opts.remotehost, cli_opts.remoteport); |
74 | 82 |
75 cli_session(sock, hostandport); | 83 cli_session(sock_in, sock_out, hostandport); |
76 | 84 |
77 /* not reached */ | 85 /* not reached */ |
78 return -1; | 86 return -1; |
79 } | 87 } |
80 #endif /* DBMULTI stuff */ | 88 #endif /* DBMULTI stuff */ |