Mercurial > dropbear
comparison cli-main.c @ 483:738313e73b1c
- "-J 'nc localhost 22'" kind of works, needs fixing hostkeys, ptys etc.
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 15 Sep 2008 14:40:30 +0000 |
parents | e3db1f7a2e43 |
children | effb4a25b1ae |
comparison
equal
deleted
inserted
replaced
482:7ad49f34a122 | 483:738313e73b1c |
---|---|
30 #include "session.h" | 30 #include "session.h" |
31 | 31 |
32 static void cli_dropbear_exit(int exitcode, const char* format, va_list param); | 32 static void cli_dropbear_exit(int exitcode, const char* format, va_list param); |
33 static void cli_dropbear_log(int priority, const char* format, va_list param); | 33 static void cli_dropbear_log(int priority, const char* format, va_list param); |
34 | 34 |
35 static void cli_proxy_cmd(int *sock_in, int *sock_out); | |
36 | |
35 #if defined(DBMULTI_dbclient) || !defined(DROPBEAR_MULTI) | 37 #if defined(DBMULTI_dbclient) || !defined(DROPBEAR_MULTI) |
36 #if defined(DBMULTI_dbclient) && defined(DROPBEAR_MULTI) | 38 #if defined(DBMULTI_dbclient) && defined(DROPBEAR_MULTI) |
37 int cli_main(int argc, char ** argv) { | 39 int cli_main(int argc, char ** argv) { |
38 #else | 40 #else |
39 int main(int argc, char ** argv) { | 41 int main(int argc, char ** argv) { |
56 | 58 |
57 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { | 59 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { |
58 dropbear_exit("signal() error"); | 60 dropbear_exit("signal() error"); |
59 } | 61 } |
60 | 62 |
61 #ifdef CLI_ENABLE_PROXYCMD | 63 #ifdef ENABLE_CLI_PROXYCMD |
62 if (cli_runopts.proxycmd) { | 64 if (cli_opts.proxycmd) { |
63 | 65 cli_proxy_cmd(&sock_in, &sock_out); |
64 } else | 66 } else |
65 #endif | 67 #endif |
66 { | 68 { |
67 int sock = connect_remote(cli_opts.remotehost, cli_opts.remoteport, | 69 int sock = connect_remote(cli_opts.remotehost, cli_opts.remoteport, |
68 0, &error); | 70 0, &error); |
118 vsnprintf(printbuf, sizeof(printbuf), format, param); | 120 vsnprintf(printbuf, sizeof(printbuf), format, param); |
119 | 121 |
120 fprintf(stderr, "%s: %s\n", cli_opts.progname, printbuf); | 122 fprintf(stderr, "%s: %s\n", cli_opts.progname, printbuf); |
121 | 123 |
122 } | 124 } |
125 | |
126 static void exec_proxy_cmd(void *user_data_cmd) { | |
127 const char *cmd = user_data_cmd; | |
128 char *usershell; | |
129 | |
130 usershell = m_strdup(get_user_shell()); | |
131 run_shell_command(cmd, ses.maxfd, usershell); | |
132 dropbear_exit("Failed to run '%s'\n", cmd); | |
133 } | |
134 | |
135 static void cli_proxy_cmd(int *sock_in, int *sock_out) { | |
136 int ret; | |
137 int errfd; | |
138 pid_t pid; | |
139 | |
140 fill_passwd(cli_opts.own_user); | |
141 | |
142 ret = spawn_command(exec_proxy_cmd, cli_opts.proxycmd, | |
143 sock_out, sock_in, &errfd, &pid); | |
144 if (ret == DROPBEAR_FAILURE) { | |
145 dropbear_exit("Failed running proxy command"); | |
146 *sock_in = *sock_out = -1; | |
147 } | |
148 } |