diff options
author | Matt Johnston <matt@ucc.asn.au> | 2008-09-15 14:40:30 +0000 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2008-09-15 14:40:30 +0000 |
commit | e44aa503f0b816adb1611f118c1c09877e7bb3d3 (patch) | |
tree | 7a61beef6721f51dfdc1d9d2c3696b0b55a69e41 /cli-main.c | |
parent | 12929e8cf09bf16ad59e04eaa20f31282bd58e30 (diff) |
- "-J 'nc localhost 22'" kind of works, needs fixing hostkeys, ptys etc.
--HG--
extra : convert_revision : 45069dd007ebf414330e0a7abf4fb7e0727049c3
Diffstat (limited to 'cli-main.c')
-rw-r--r-- | cli-main.c | 32 |
1 files changed, 29 insertions, 3 deletions
@@ -32,6 +32,8 @@ static void cli_dropbear_exit(int exitcode, const char* format, va_list param); static void cli_dropbear_log(int priority, const char* format, va_list param); +static void cli_proxy_cmd(int *sock_in, int *sock_out); + #if defined(DBMULTI_dbclient) || !defined(DROPBEAR_MULTI) #if defined(DBMULTI_dbclient) && defined(DROPBEAR_MULTI) int cli_main(int argc, char ** argv) { @@ -58,9 +60,9 @@ int main(int argc, char ** argv) { dropbear_exit("signal() error"); } -#ifdef CLI_ENABLE_PROXYCMD - if (cli_runopts.proxycmd) { - +#ifdef ENABLE_CLI_PROXYCMD + if (cli_opts.proxycmd) { + cli_proxy_cmd(&sock_in, &sock_out); } else #endif { @@ -120,3 +122,27 @@ static void cli_dropbear_log(int UNUSED(priority), fprintf(stderr, "%s: %s\n", cli_opts.progname, printbuf); } + +static void exec_proxy_cmd(void *user_data_cmd) { + const char *cmd = user_data_cmd; + char *usershell; + + usershell = m_strdup(get_user_shell()); + run_shell_command(cmd, ses.maxfd, usershell); + dropbear_exit("Failed to run '%s'\n", cmd); +} + +static void cli_proxy_cmd(int *sock_in, int *sock_out) { + int ret; + int errfd; + pid_t pid; + + fill_passwd(cli_opts.own_user); + + ret = spawn_command(exec_proxy_cmd, cli_opts.proxycmd, + sock_out, sock_in, &errfd, &pid); + if (ret == DROPBEAR_FAILURE) { + dropbear_exit("Failed running proxy command"); + *sock_in = *sock_out = -1; + } +} |