Mercurial > dropbear
comparison cli-runopts.c @ 1295:750ec4ec4cbe
Convert #ifdef to #if, other build changes
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 04 May 2016 15:33:40 +0200 |
parents | 9169e4e7cbee |
children | e8f67918fdc9 |
comparison
equal
deleted
inserted
replaced
1294:56aba7dedbea | 1295:750ec4ec4cbe |
---|---|
35 | 35 |
36 static void printhelp(void); | 36 static void printhelp(void); |
37 static void parse_hostname(const char* orighostarg); | 37 static void parse_hostname(const char* orighostarg); |
38 static void parse_multihop_hostname(const char* orighostarg, const char* argv0); | 38 static void parse_multihop_hostname(const char* orighostarg, const char* argv0); |
39 static void fill_own_user(void); | 39 static void fill_own_user(void); |
40 #ifdef ENABLE_CLI_PUBKEY_AUTH | 40 #if DROPBEAR_CLI_PUBKEY_AUTH |
41 static void loadidentityfile(const char* filename, int warnfail); | 41 static void loadidentityfile(const char* filename, int warnfail); |
42 #endif | 42 #endif |
43 #ifdef ENABLE_CLI_ANYTCPFWD | 43 #if DROPBEAR_CLI_ANYTCPFWD |
44 static void addforward(const char* str, m_list *fwdlist); | 44 static void addforward(const char* str, m_list *fwdlist); |
45 #endif | 45 #endif |
46 #ifdef ENABLE_CLI_NETCAT | 46 #if DROPBEAR_CLI_NETCAT |
47 static void add_netcat(const char *str); | 47 static void add_netcat(const char *str); |
48 #endif | 48 #endif |
49 static void add_extendedopt(const char *str); | 49 static void add_extendedopt(const char *str); |
50 | 50 |
51 static void printhelp() { | 51 static void printhelp() { |
52 | 52 |
53 fprintf(stderr, "Dropbear SSH client v%s https://matt.ucc.asn.au/dropbear/dropbear.html\n" | 53 fprintf(stderr, "Dropbear SSH client v%s https://matt.ucc.asn.au/dropbear/dropbear.html\n" |
54 #ifdef ENABLE_CLI_MULTIHOP | 54 #if DROPBEAR_CLI_MULTIHOP |
55 "Usage: %s [options] [user@]host[/port][,[user@]host/port],...] [command]\n" | 55 "Usage: %s [options] [user@]host[/port][,[user@]host/port],...] [command]\n" |
56 #else | 56 #else |
57 "Usage: %s [options] [user@]host[/port] [command]\n" | 57 "Usage: %s [options] [user@]host[/port] [command]\n" |
58 #endif | 58 #endif |
59 "-p <remoteport>\n" | 59 "-p <remoteport>\n" |
64 "-f Run in background after auth\n" | 64 "-f Run in background after auth\n" |
65 "-y Always accept remote host key if unknown\n" | 65 "-y Always accept remote host key if unknown\n" |
66 "-y -y Don't perform any remote host key checking (caution)\n" | 66 "-y -y Don't perform any remote host key checking (caution)\n" |
67 "-s Request a subsystem (use by external sftp)\n" | 67 "-s Request a subsystem (use by external sftp)\n" |
68 "-o option Set option in OpenSSH-like format ('-o help' to list options)\n" | 68 "-o option Set option in OpenSSH-like format ('-o help' to list options)\n" |
69 #ifdef ENABLE_CLI_PUBKEY_AUTH | 69 #if DROPBEAR_CLI_PUBKEY_AUTH |
70 "-i <identityfile> (multiple allowed, default %s)\n" | 70 "-i <identityfile> (multiple allowed, default %s)\n" |
71 #endif | 71 #endif |
72 #ifdef ENABLE_CLI_AGENTFWD | 72 #if DROPBEAR_CLI_AGENTFWD |
73 "-A Enable agent auth forwarding\n" | 73 "-A Enable agent auth forwarding\n" |
74 #endif | 74 #endif |
75 #ifdef ENABLE_CLI_LOCALTCPFWD | 75 #if DROPBEAR_CLI_LOCALTCPFWD |
76 "-L <[listenaddress:]listenport:remotehost:remoteport> Local port forwarding\n" | 76 "-L <[listenaddress:]listenport:remotehost:remoteport> Local port forwarding\n" |
77 "-g Allow remote hosts to connect to forwarded ports\n" | 77 "-g Allow remote hosts to connect to forwarded ports\n" |
78 #endif | 78 #endif |
79 #ifdef ENABLE_CLI_REMOTETCPFWD | 79 #if DROPBEAR_CLI_REMOTETCPFWD |
80 "-R <[listenaddress:]listenport:remotehost:remoteport> Remote port forwarding\n" | 80 "-R <[listenaddress:]listenport:remotehost:remoteport> Remote port forwarding\n" |
81 #endif | 81 #endif |
82 "-W <receive_window_buffer> (default %d, larger may be faster, max 1MB)\n" | 82 "-W <receive_window_buffer> (default %d, larger may be faster, max 1MB)\n" |
83 "-K <keepalive> (0 is never, default %d)\n" | 83 "-K <keepalive> (0 is never, default %d)\n" |
84 "-I <idle_timeout> (0 is never, default %d)\n" | 84 "-I <idle_timeout> (0 is never, default %d)\n" |
85 #ifdef ENABLE_CLI_NETCAT | 85 #if DROPBEAR_CLI_NETCAT |
86 "-B <endhost:endport> Netcat-alike forwarding\n" | 86 "-B <endhost:endport> Netcat-alike forwarding\n" |
87 #endif | 87 #endif |
88 #ifdef ENABLE_CLI_PROXYCMD | 88 #if DROPBEAR_CLI_PROXYCMD |
89 "-J <proxy_program> Use program pipe rather than TCP connection\n" | 89 "-J <proxy_program> Use program pipe rather than TCP connection\n" |
90 #endif | 90 #endif |
91 #ifdef ENABLE_USER_ALGO_LIST | 91 #if DROPBEAR_USER_ALGO_LIST |
92 "-c <cipher list> Specify preferred ciphers ('-c help' to list options)\n" | 92 "-c <cipher list> Specify preferred ciphers ('-c help' to list options)\n" |
93 "-m <MAC list> Specify preferred MACs for packet verification (or '-m help')\n" | 93 "-m <MAC list> Specify preferred MACs for packet verification (or '-m help')\n" |
94 #endif | 94 #endif |
95 "-V Version\n" | 95 "-V Version\n" |
96 #ifdef DEBUG_TRACE | 96 #if DEBUG_TRACE |
97 "-v verbose (compiled with DEBUG_TRACE)\n" | 97 "-v verbose (compiled with DEBUG_TRACE)\n" |
98 #endif | 98 #endif |
99 ,DROPBEAR_VERSION, cli_opts.progname, | 99 ,DROPBEAR_VERSION, cli_opts.progname, |
100 #ifdef ENABLE_CLI_PUBKEY_AUTH | 100 #if DROPBEAR_CLI_PUBKEY_AUTH |
101 DROPBEAR_DEFAULT_CLI_AUTHKEY, | 101 DROPBEAR_DEFAULT_CLI_AUTHKEY, |
102 #endif | 102 #endif |
103 DEFAULT_RECV_WINDOW, DEFAULT_KEEPALIVE, DEFAULT_IDLE_TIMEOUT); | 103 DEFAULT_RECV_WINDOW, DEFAULT_KEEPALIVE, DEFAULT_IDLE_TIMEOUT); |
104 | 104 |
105 } | 105 } |
107 void cli_getopts(int argc, char ** argv) { | 107 void cli_getopts(int argc, char ** argv) { |
108 unsigned int i, j; | 108 unsigned int i, j; |
109 char ** next = 0; | 109 char ** next = 0; |
110 enum { | 110 enum { |
111 OPT_EXTENDED_OPTIONS, | 111 OPT_EXTENDED_OPTIONS, |
112 #ifdef ENABLE_CLI_PUBKEY_AUTH | 112 #if DROPBEAR_CLI_PUBKEY_AUTH |
113 OPT_AUTHKEY, | 113 OPT_AUTHKEY, |
114 #endif | 114 #endif |
115 #ifdef ENABLE_CLI_LOCALTCPFWD | 115 #if DROPBEAR_CLI_LOCALTCPFWD |
116 OPT_LOCALTCPFWD, | 116 OPT_LOCALTCPFWD, |
117 #endif | 117 #endif |
118 #ifdef ENABLE_CLI_REMOTETCPFWD | 118 #if DROPBEAR_CLI_REMOTETCPFWD |
119 OPT_REMOTETCPFWD, | 119 OPT_REMOTETCPFWD, |
120 #endif | 120 #endif |
121 #ifdef ENABLE_CLI_NETCAT | 121 #if DROPBEAR_CLI_NETCAT |
122 OPT_NETCAT, | 122 OPT_NETCAT, |
123 #endif | 123 #endif |
124 /* a flag (no arg) if 'next' is NULL, a string-valued option otherwise */ | 124 /* a flag (no arg) if 'next' is NULL, a string-valued option otherwise */ |
125 OPT_OTHER | 125 OPT_OTHER |
126 } opt; | 126 } opt; |
143 cli_opts.backgrounded = 0; | 143 cli_opts.backgrounded = 0; |
144 cli_opts.wantpty = 9; /* 9 means "it hasn't been touched", gets set later */ | 144 cli_opts.wantpty = 9; /* 9 means "it hasn't been touched", gets set later */ |
145 cli_opts.always_accept_key = 0; | 145 cli_opts.always_accept_key = 0; |
146 cli_opts.no_hostkey_check = 0; | 146 cli_opts.no_hostkey_check = 0; |
147 cli_opts.is_subsystem = 0; | 147 cli_opts.is_subsystem = 0; |
148 #ifdef ENABLE_CLI_PUBKEY_AUTH | 148 #if DROPBEAR_CLI_PUBKEY_AUTH |
149 cli_opts.privkeys = list_new(); | 149 cli_opts.privkeys = list_new(); |
150 #endif | 150 #endif |
151 #ifdef ENABLE_CLI_ANYTCPFWD | 151 #if DROPBEAR_CLI_ANYTCPFWD |
152 cli_opts.exit_on_fwd_failure = 0; | 152 cli_opts.exit_on_fwd_failure = 0; |
153 #endif | 153 #endif |
154 #ifdef ENABLE_CLI_LOCALTCPFWD | 154 #if DROPBEAR_CLI_LOCALTCPFWD |
155 cli_opts.localfwds = list_new(); | 155 cli_opts.localfwds = list_new(); |
156 opts.listen_fwd_all = 0; | 156 opts.listen_fwd_all = 0; |
157 #endif | 157 #endif |
158 #ifdef ENABLE_CLI_REMOTETCPFWD | 158 #if DROPBEAR_CLI_REMOTETCPFWD |
159 cli_opts.remotefwds = list_new(); | 159 cli_opts.remotefwds = list_new(); |
160 #endif | 160 #endif |
161 #ifdef ENABLE_CLI_AGENTFWD | 161 #if DROPBEAR_CLI_AGENTFWD |
162 cli_opts.agent_fwd = 0; | 162 cli_opts.agent_fwd = 0; |
163 cli_opts.agent_fd = -1; | 163 cli_opts.agent_fd = -1; |
164 cli_opts.agent_keys_loaded = 0; | 164 cli_opts.agent_keys_loaded = 0; |
165 #endif | 165 #endif |
166 #ifdef ENABLE_CLI_PROXYCMD | 166 #if DROPBEAR_CLI_PROXYCMD |
167 cli_opts.proxycmd = NULL; | 167 cli_opts.proxycmd = NULL; |
168 #endif | 168 #endif |
169 #ifndef DISABLE_ZLIB | 169 #ifndef DISABLE_ZLIB |
170 opts.compress_mode = DROPBEAR_COMPRESS_ON; | 170 opts.compress_mode = DROPBEAR_COMPRESS_ON; |
171 #endif | 171 #endif |
172 #ifdef ENABLE_USER_ALGO_LIST | 172 #if DROPBEAR_USER_ALGO_LIST |
173 opts.cipher_list = NULL; | 173 opts.cipher_list = NULL; |
174 opts.mac_list = NULL; | 174 opts.mac_list = NULL; |
175 #endif | 175 #endif |
176 #ifndef DISABLE_SYSLOG | 176 #ifndef DISABLE_SYSLOG |
177 opts.usingsyslog = 0; | 177 opts.usingsyslog = 0; |
211 cli_opts.always_accept_key = 1; | 211 cli_opts.always_accept_key = 1; |
212 break; | 212 break; |
213 case 'p': /* remoteport */ | 213 case 'p': /* remoteport */ |
214 next = &cli_opts.remoteport; | 214 next = &cli_opts.remoteport; |
215 break; | 215 break; |
216 #ifdef ENABLE_CLI_PUBKEY_AUTH | 216 #if DROPBEAR_CLI_PUBKEY_AUTH |
217 case 'i': /* an identityfile */ | 217 case 'i': /* an identityfile */ |
218 opt = OPT_AUTHKEY; | 218 opt = OPT_AUTHKEY; |
219 break; | 219 break; |
220 #endif | 220 #endif |
221 case 't': /* we want a pty */ | 221 case 't': /* we want a pty */ |
234 cli_opts.is_subsystem = 1; | 234 cli_opts.is_subsystem = 1; |
235 break; | 235 break; |
236 case 'o': | 236 case 'o': |
237 opt = OPT_EXTENDED_OPTIONS; | 237 opt = OPT_EXTENDED_OPTIONS; |
238 break; | 238 break; |
239 #ifdef ENABLE_CLI_LOCALTCPFWD | 239 #if DROPBEAR_CLI_LOCALTCPFWD |
240 case 'L': | 240 case 'L': |
241 opt = OPT_LOCALTCPFWD; | 241 opt = OPT_LOCALTCPFWD; |
242 break; | 242 break; |
243 case 'g': | 243 case 'g': |
244 opts.listen_fwd_all = 1; | 244 opts.listen_fwd_all = 1; |
245 break; | 245 break; |
246 #endif | 246 #endif |
247 #ifdef ENABLE_CLI_REMOTETCPFWD | 247 #if DROPBEAR_CLI_REMOTETCPFWD |
248 case 'R': | 248 case 'R': |
249 opt = OPT_REMOTETCPFWD; | 249 opt = OPT_REMOTETCPFWD; |
250 break; | 250 break; |
251 #endif | 251 #endif |
252 #ifdef ENABLE_CLI_NETCAT | 252 #if DROPBEAR_CLI_NETCAT |
253 case 'B': | 253 case 'B': |
254 opt = OPT_NETCAT; | 254 opt = OPT_NETCAT; |
255 break; | 255 break; |
256 #endif | 256 #endif |
257 #ifdef ENABLE_CLI_PROXYCMD | 257 #if DROPBEAR_CLI_PROXYCMD |
258 case 'J': | 258 case 'J': |
259 next = &cli_opts.proxycmd; | 259 next = &cli_opts.proxycmd; |
260 break; | 260 break; |
261 #endif | 261 #endif |
262 case 'l': | 262 case 'l': |
276 next = &keepalive_arg; | 276 next = &keepalive_arg; |
277 break; | 277 break; |
278 case 'I': | 278 case 'I': |
279 next = &idle_timeout_arg; | 279 next = &idle_timeout_arg; |
280 break; | 280 break; |
281 #ifdef ENABLE_CLI_AGENTFWD | 281 #if DROPBEAR_CLI_AGENTFWD |
282 case 'A': | 282 case 'A': |
283 cli_opts.agent_fwd = 1; | 283 cli_opts.agent_fwd = 1; |
284 break; | 284 break; |
285 #endif | 285 #endif |
286 #ifdef ENABLE_USER_ALGO_LIST | 286 #if DROPBEAR_USER_ALGO_LIST |
287 case 'c': | 287 case 'c': |
288 next = &opts.cipher_list; | 288 next = &opts.cipher_list; |
289 break; | 289 break; |
290 case 'm': | 290 case 'm': |
291 next = &opts.mac_list; | 291 next = &opts.mac_list; |
292 break; | 292 break; |
293 #endif | 293 #endif |
294 #ifdef DEBUG_TRACE | 294 #if DEBUG_TRACE |
295 case 'v': | 295 case 'v': |
296 debug_trace = 1; | 296 debug_trace = 1; |
297 break; | 297 break; |
298 #endif | 298 #endif |
299 case 'F': | 299 case 'F': |
300 case 'e': | 300 case 'e': |
301 #ifndef ENABLE_USER_ALGO_LIST | 301 #if !DROPBEAR_USER_ALGO_LIST |
302 case 'c': | 302 case 'c': |
303 case 'm': | 303 case 'm': |
304 #endif | 304 #endif |
305 case 'D': | 305 case 'D': |
306 #ifndef ENABLE_CLI_REMOTETCPFWD | 306 #ifndef DROPBEAR_CLI_REMOTETCPFWD |
307 case 'R': | 307 case 'R': |
308 #endif | 308 #endif |
309 #ifndef ENABLE_CLI_LOCALTCPFWD | 309 #ifndef DROPBEAR_CLI_LOCALTCPFWD |
310 case 'L': | 310 case 'L': |
311 #endif | 311 #endif |
312 case 'V': | 312 case 'V': |
313 print_version(); | 313 print_version(); |
314 exit(EXIT_SUCCESS); | 314 exit(EXIT_SUCCESS); |
336 if (opt == OPT_EXTENDED_OPTIONS) { | 336 if (opt == OPT_EXTENDED_OPTIONS) { |
337 TRACE(("opt extended")) | 337 TRACE(("opt extended")) |
338 add_extendedopt(&argv[i][j]); | 338 add_extendedopt(&argv[i][j]); |
339 } | 339 } |
340 else | 340 else |
341 #ifdef ENABLE_CLI_PUBKEY_AUTH | 341 #if DROPBEAR_CLI_PUBKEY_AUTH |
342 if (opt == OPT_AUTHKEY) { | 342 if (opt == OPT_AUTHKEY) { |
343 TRACE(("opt authkey")) | 343 TRACE(("opt authkey")) |
344 loadidentityfile(&argv[i][j], 1); | 344 loadidentityfile(&argv[i][j], 1); |
345 } | 345 } |
346 else | 346 else |
347 #endif | 347 #endif |
348 #ifdef ENABLE_CLI_REMOTETCPFWD | 348 #if DROPBEAR_CLI_REMOTETCPFWD |
349 if (opt == OPT_REMOTETCPFWD) { | 349 if (opt == OPT_REMOTETCPFWD) { |
350 TRACE(("opt remotetcpfwd")) | 350 TRACE(("opt remotetcpfwd")) |
351 addforward(&argv[i][j], cli_opts.remotefwds); | 351 addforward(&argv[i][j], cli_opts.remotefwds); |
352 } | 352 } |
353 else | 353 else |
354 #endif | 354 #endif |
355 #ifdef ENABLE_CLI_LOCALTCPFWD | 355 #if DROPBEAR_CLI_LOCALTCPFWD |
356 if (opt == OPT_LOCALTCPFWD) { | 356 if (opt == OPT_LOCALTCPFWD) { |
357 TRACE(("opt localtcpfwd")) | 357 TRACE(("opt localtcpfwd")) |
358 addforward(&argv[i][j], cli_opts.localfwds); | 358 addforward(&argv[i][j], cli_opts.localfwds); |
359 } | 359 } |
360 else | 360 else |
361 #endif | 361 #endif |
362 #ifdef ENABLE_CLI_NETCAT | 362 #if DROPBEAR_CLI_NETCAT |
363 if (opt == OPT_NETCAT) { | 363 if (opt == OPT_NETCAT) { |
364 TRACE(("opt netcat")) | 364 TRACE(("opt netcat")) |
365 add_netcat(&argv[i][j]); | 365 add_netcat(&argv[i][j]); |
366 } | 366 } |
367 else | 367 else |
403 TRACE(("cmd is: %s", cli_opts.cmd)) | 403 TRACE(("cmd is: %s", cli_opts.cmd)) |
404 } | 404 } |
405 | 405 |
406 /* And now a few sanity checks and setup */ | 406 /* And now a few sanity checks and setup */ |
407 | 407 |
408 #ifdef ENABLE_USER_ALGO_LIST | 408 #if DROPBEAR_USER_ALGO_LIST |
409 parse_ciphers_macs(); | 409 parse_ciphers_macs(); |
410 #endif | 410 #endif |
411 | 411 |
412 #ifdef ENABLE_CLI_PROXYCMD | 412 #if DROPBEAR_CLI_PROXYCMD |
413 if (cli_opts.proxycmd) { | 413 if (cli_opts.proxycmd) { |
414 /* To match the common path of m_freeing it */ | 414 /* To match the common path of m_freeing it */ |
415 cli_opts.proxycmd = m_strdup(cli_opts.proxycmd); | 415 cli_opts.proxycmd = m_strdup(cli_opts.proxycmd); |
416 } | 416 } |
417 #endif | 417 #endif |
455 dropbear_exit("Bad idle_timeout '%s'", idle_timeout_arg); | 455 dropbear_exit("Bad idle_timeout '%s'", idle_timeout_arg); |
456 } | 456 } |
457 opts.idle_timeout_secs = val; | 457 opts.idle_timeout_secs = val; |
458 } | 458 } |
459 | 459 |
460 #ifdef ENABLE_CLI_NETCAT | 460 #if DROPBEAR_CLI_NETCAT |
461 if (cli_opts.cmd && cli_opts.netcat_host) { | 461 if (cli_opts.cmd && cli_opts.netcat_host) { |
462 dropbear_log(LOG_INFO, "Ignoring command '%s' in netcat mode", cli_opts.cmd); | 462 dropbear_log(LOG_INFO, "Ignoring command '%s' in netcat mode", cli_opts.cmd); |
463 } | 463 } |
464 #endif | 464 #endif |
465 | 465 |
466 #if defined(DROPBEAR_DEFAULT_CLI_AUTHKEY) && defined(ENABLE_CLI_PUBKEY_AUTH) | 466 #if (DROPBEAR_CLI_PUBKEY_AUTH) |
467 { | 467 { |
468 char *expand_path = expand_homedir_path(DROPBEAR_DEFAULT_CLI_AUTHKEY); | 468 char *expand_path = expand_homedir_path(DROPBEAR_DEFAULT_CLI_AUTHKEY); |
469 loadidentityfile(expand_path, 0); | 469 loadidentityfile(expand_path, 0); |
470 m_free(expand_path); | 470 m_free(expand_path); |
471 } | 471 } |
472 #endif | 472 #endif |
473 | 473 |
474 /* The hostname gets set up last, since | 474 /* The hostname gets set up last, since |
475 * in multi-hop mode it will require knowledge | 475 * in multi-hop mode it will require knowledge |
476 * of other flags such as -i */ | 476 * of other flags such as -i */ |
477 #ifdef ENABLE_CLI_MULTIHOP | 477 #if DROPBEAR_CLI_MULTIHOP |
478 parse_multihop_hostname(host_arg, argv[0]); | 478 parse_multihop_hostname(host_arg, argv[0]); |
479 #else | 479 #else |
480 parse_hostname(host_arg); | 480 parse_hostname(host_arg); |
481 #endif | 481 #endif |
482 } | 482 } |
483 | 483 |
484 #ifdef ENABLE_CLI_PUBKEY_AUTH | 484 #if DROPBEAR_CLI_PUBKEY_AUTH |
485 static void loadidentityfile(const char* filename, int warnfail) { | 485 static void loadidentityfile(const char* filename, int warnfail) { |
486 sign_key *key; | 486 sign_key *key; |
487 enum signkey_type keytype; | 487 enum signkey_type keytype; |
488 | 488 |
489 TRACE(("loadidentityfile %s", filename)) | 489 TRACE(("loadidentityfile %s", filename)) |
502 list_append(cli_opts.privkeys, key); | 502 list_append(cli_opts.privkeys, key); |
503 } | 503 } |
504 } | 504 } |
505 #endif | 505 #endif |
506 | 506 |
507 #ifdef ENABLE_CLI_MULTIHOP | 507 #if DROPBEAR_CLI_MULTIHOP |
508 | 508 |
509 static char* | 509 static char* |
510 multihop_passthrough_args() { | 510 multihop_passthrough_args() { |
511 char *ret; | 511 char *ret; |
512 int total; | 512 int total; |
513 unsigned int len = 0; | 513 unsigned int len = 0; |
514 m_list_elem *iter; | 514 m_list_elem *iter; |
515 /* Fill out -i, -y, -W options that make sense for all | 515 /* Fill out -i, -y, -W options that make sense for all |
516 * the intermediate processes */ | 516 * the intermediate processes */ |
517 #ifdef ENABLE_CLI_PUBKEY_AUTH | 517 #if DROPBEAR_CLI_PUBKEY_AUTH |
518 for (iter = cli_opts.privkeys->first; iter; iter = iter->next) | 518 for (iter = cli_opts.privkeys->first; iter; iter = iter->next) |
519 { | 519 { |
520 sign_key * key = (sign_key*)iter->item; | 520 sign_key * key = (sign_key*)iter->item; |
521 len += 3 + strlen(key->filename); | 521 len += 3 + strlen(key->filename); |
522 } | 522 } |
523 #endif /* ENABLE_CLI_PUBKEY_AUTH */ | 523 #endif /* DROPBEAR_CLI_PUBKEY_AUTH */ |
524 | 524 |
525 len += 30; /* space for -W <size>, terminator. */ | 525 len += 30; /* space for -W <size>, terminator. */ |
526 ret = m_malloc(len); | 526 ret = m_malloc(len); |
527 total = 0; | 527 total = 0; |
528 | 528 |
541 { | 541 { |
542 int written = snprintf(ret+total, len-total, "-W %u ", opts.recv_window); | 542 int written = snprintf(ret+total, len-total, "-W %u ", opts.recv_window); |
543 total += written; | 543 total += written; |
544 } | 544 } |
545 | 545 |
546 #ifdef ENABLE_CLI_PUBKEY_AUTH | 546 #if DROPBEAR_CLI_PUBKEY_AUTH |
547 for (iter = cli_opts.privkeys->first; iter; iter = iter->next) | 547 for (iter = cli_opts.privkeys->first; iter; iter = iter->next) |
548 { | 548 { |
549 sign_key * key = (sign_key*)iter->item; | 549 sign_key * key = (sign_key*)iter->item; |
550 const size_t size = len - total; | 550 const size_t size = len - total; |
551 int written = snprintf(ret+total, size, "-i %s ", key->filename); | 551 int written = snprintf(ret+total, size, "-i %s ", key->filename); |
552 dropbear_assert((unsigned int)written < size); | 552 dropbear_assert((unsigned int)written < size); |
553 total += written; | 553 total += written; |
554 } | 554 } |
555 #endif /* ENABLE_CLI_PUBKEY_AUTH */ | 555 #endif /* DROPBEAR_CLI_PUBKEY_AUTH */ |
556 | 556 |
557 /* if args were passed, total will be not zero, and it will have a space at the end, so remove that */ | 557 /* if args were passed, total will be not zero, and it will have a space at the end, so remove that */ |
558 if (total > 0) | 558 if (total > 0) |
559 { | 559 { |
560 total--; | 560 total--; |
634 #endif | 634 #endif |
635 m_free(passthrough_args); | 635 m_free(passthrough_args); |
636 } | 636 } |
637 m_free(hostbuf); | 637 m_free(hostbuf); |
638 } | 638 } |
639 #endif /* !ENABLE_CLI_MULTIHOP */ | 639 #endif /* !DROPBEAR_CLI_MULTIHOP */ |
640 | 640 |
641 /* Parses a [user@]hostname[/port] argument. */ | 641 /* Parses a [user@]hostname[/port] argument. */ |
642 static void parse_hostname(const char* orighostarg) { | 642 static void parse_hostname(const char* orighostarg) { |
643 char *userhostarg = NULL; | 643 char *userhostarg = NULL; |
644 char *port = NULL; | 644 char *port = NULL; |
673 if (cli_opts.remotehost[0] == '\0') { | 673 if (cli_opts.remotehost[0] == '\0') { |
674 dropbear_exit("Bad hostname"); | 674 dropbear_exit("Bad hostname"); |
675 } | 675 } |
676 } | 676 } |
677 | 677 |
678 #ifdef ENABLE_CLI_NETCAT | 678 #if DROPBEAR_CLI_NETCAT |
679 static void add_netcat(const char* origstr) { | 679 static void add_netcat(const char* origstr) { |
680 char *portstr = NULL; | 680 char *portstr = NULL; |
681 | 681 |
682 char * str = m_strdup(origstr); | 682 char * str = m_strdup(origstr); |
683 | 683 |
726 cli_opts.own_user = m_strdup("unknown"); | 726 cli_opts.own_user = m_strdup("unknown"); |
727 } | 727 } |
728 | 728 |
729 } | 729 } |
730 | 730 |
731 #ifdef ENABLE_CLI_ANYTCPFWD | 731 #if DROPBEAR_CLI_ANYTCPFWD |
732 /* Turn a "[listenaddr:]listenport:remoteaddr:remoteport" string into into a forwarding | 732 /* Turn a "[listenaddr:]listenport:remoteaddr:remoteport" string into into a forwarding |
733 * set, and add it to the forwarding list */ | 733 * set, and add it to the forwarding list */ |
734 static void addforward(const char* origstr, m_list *fwdlist) { | 734 static void addforward(const char* origstr, m_list *fwdlist) { |
735 | 735 |
736 char *part1 = NULL, *part2 = NULL, *part3 = NULL, *part4 = NULL; | 736 char *part1 = NULL, *part2 = NULL, *part3 = NULL, *part4 = NULL; |
868 static void add_extendedopt(const char* origstr) { | 868 static void add_extendedopt(const char* origstr) { |
869 const char *optstr = origstr; | 869 const char *optstr = origstr; |
870 | 870 |
871 if (strcmp(origstr, "help") == 0) { | 871 if (strcmp(origstr, "help") == 0) { |
872 dropbear_log(LOG_INFO, "Available options:\n" | 872 dropbear_log(LOG_INFO, "Available options:\n" |
873 #ifdef ENABLE_CLI_ANYTCPFWD | 873 #if DROPBEAR_CLI_ANYTCPFWD |
874 "\tExitOnForwardFailure\n" | 874 "\tExitOnForwardFailure\n" |
875 #endif | 875 #endif |
876 #ifndef DISABLE_SYSLOG | 876 #ifndef DISABLE_SYSLOG |
877 "\tUseSyslog\n" | 877 "\tUseSyslog\n" |
878 #endif | 878 #endif |
879 ); | 879 ); |
880 exit(EXIT_SUCCESS); | 880 exit(EXIT_SUCCESS); |
881 } | 881 } |
882 | 882 |
883 #ifdef ENABLE_CLI_ANYTCPFWD | 883 #if DROPBEAR_CLI_ANYTCPFWD |
884 if (match_extendedopt(&optstr, "ExitOnForwardFailure") == DROPBEAR_SUCCESS) { | 884 if (match_extendedopt(&optstr, "ExitOnForwardFailure") == DROPBEAR_SUCCESS) { |
885 cli_opts.exit_on_fwd_failure = parse_flag_value(optstr); | 885 cli_opts.exit_on_fwd_failure = parse_flag_value(optstr); |
886 return; | 886 return; |
887 } | 887 } |
888 #endif | 888 #endif |