Skip to content

Commit 5cc0127

Browse files
rockdrillamkj
authored andcommitted
Fix proxycmd without netcat
fixes e5a0ef2 "Execute multihop commands directly, no shell" Signed-off-by: Konstantin Demin <[email protected]>
1 parent dbb998c commit 5cc0127

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/cli-main.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ int main(int argc, char ** argv) {
7777
}
7878

7979
#if DROPBEAR_CLI_PROXYCMD
80-
if (cli_opts.proxycmd || cli_opts.proxyexec) {
80+
if (cli_opts.proxycmd
81+
#if DROPBEAR_CLI_MULTIHOP
82+
|| cli_opts.proxyexec
83+
#endif
84+
) {
8185
cli_proxy_cmd(&sock_in, &sock_out, &proxy_cmd_pid);
8286
if (signal(SIGINT, kill_proxy_sighandler) == SIG_ERR ||
8387
signal(SIGTERM, kill_proxy_sighandler) == SIG_ERR ||
@@ -110,11 +114,13 @@ static void shell_proxy_cmd(const void *user_data_cmd) {
110114
dropbear_exit("Failed to run '%s'\n", cmd);
111115
}
112116

117+
#if DROPBEAR_CLI_MULTIHOP
113118
static void exec_proxy_cmd(const void *unused) {
114119
(void)unused;
115120
run_command(cli_opts.proxyexec[0], cli_opts.proxyexec, ses.maxfd);
116121
dropbear_exit("Failed to run '%s'\n", cli_opts.proxyexec[0]);
117122
}
123+
#endif
118124

119125
static void cli_proxy_cmd(int *sock_in, int *sock_out, pid_t *pid_out) {
120126
char * cmd_arg = NULL;
@@ -145,9 +151,11 @@ static void cli_proxy_cmd(int *sock_in, int *sock_out, pid_t *pid_out) {
145151
cmd_arg = m_malloc(shell_cmdlen);
146152
snprintf(cmd_arg, shell_cmdlen, "exec %s", cli_opts.proxycmd);
147153
exec_fn = shell_proxy_cmd;
154+
#if DROPBEAR_CLI_MULTIHOP
148155
} else {
149156
/* No shell */
150157
exec_fn = exec_proxy_cmd;
158+
#endif
151159
}
152160

153161
ret = spawn_command(exec_fn, cmd_arg, sock_out, sock_in, NULL, pid_out);
@@ -159,13 +167,15 @@ static void cli_proxy_cmd(int *sock_in, int *sock_out, pid_t *pid_out) {
159167
cleanup:
160168
m_free(cli_opts.proxycmd);
161169
m_free(cmd_arg);
170+
#if DROPBEAR_CLI_MULTIHOP
162171
if (cli_opts.proxyexec) {
163172
char **a = NULL;
164173
for (a = cli_opts.proxyexec; *a; a++) {
165174
m_free_direct(*a);
166175
}
167176
m_free(cli_opts.proxyexec);
168177
}
178+
#endif
169179
}
170180

171181
static void kill_proxy_sighandler(int UNUSED(signo)) {

0 commit comments

Comments
 (0)