Mercurial > dropbear
comparison cli-runopts.c @ 772:7fc0aeada79c
-y -y to disable hostkey checking
fix missing trailing space when passing arguments for multihop mode
From Hans Harder
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 14 Apr 2013 22:49:10 +0800 |
parents | af4ef98b8591 |
children | f7c8b786e595 |
comparison
equal
deleted
inserted
replaced
719:1b8b2b9d6e94 | 772:7fc0aeada79c |
---|---|
60 "-t Allocate a pty\n" | 60 "-t Allocate a pty\n" |
61 "-T Don't allocate a pty\n" | 61 "-T Don't allocate a pty\n" |
62 "-N Don't run a remote command\n" | 62 "-N Don't run a remote command\n" |
63 "-f Run in background after auth\n" | 63 "-f Run in background after auth\n" |
64 "-y Always accept remote host key if unknown\n" | 64 "-y Always accept remote host key if unknown\n" |
65 "-y -y Don't perform any remote host key checking (caution)\n" | |
65 "-s Request a subsystem (use by external sftp)\n" | 66 "-s Request a subsystem (use by external sftp)\n" |
66 #ifdef ENABLE_CLI_PUBKEY_AUTH | 67 #ifdef ENABLE_CLI_PUBKEY_AUTH |
67 "-i <identityfile> (multiple allowed)\n" | 68 "-i <identityfile> (multiple allowed)\n" |
68 #endif | 69 #endif |
69 #ifdef ENABLE_CLI_AGENTFWD | 70 #ifdef ENABLE_CLI_AGENTFWD |
128 cli_opts.cmd = NULL; | 129 cli_opts.cmd = NULL; |
129 cli_opts.no_cmd = 0; | 130 cli_opts.no_cmd = 0; |
130 cli_opts.backgrounded = 0; | 131 cli_opts.backgrounded = 0; |
131 cli_opts.wantpty = 9; /* 9 means "it hasn't been touched", gets set later */ | 132 cli_opts.wantpty = 9; /* 9 means "it hasn't been touched", gets set later */ |
132 cli_opts.always_accept_key = 0; | 133 cli_opts.always_accept_key = 0; |
134 cli_opts.no_hostkey_check = 0; | |
133 cli_opts.is_subsystem = 0; | 135 cli_opts.is_subsystem = 0; |
134 #ifdef ENABLE_CLI_PUBKEY_AUTH | 136 #ifdef ENABLE_CLI_PUBKEY_AUTH |
135 cli_opts.privkeys = list_new(); | 137 cli_opts.privkeys = list_new(); |
136 #endif | 138 #endif |
137 #ifdef ENABLE_CLI_LOCALTCPFWD | 139 #ifdef ENABLE_CLI_LOCALTCPFWD |
211 if (argv[i][0] == '-') { | 213 if (argv[i][0] == '-') { |
212 /* A flag *waves* */ | 214 /* A flag *waves* */ |
213 | 215 |
214 switch (argv[i][1]) { | 216 switch (argv[i][1]) { |
215 case 'y': /* always accept the remote hostkey */ | 217 case 'y': /* always accept the remote hostkey */ |
218 if (cli_opts.always_accept_key) { | |
219 // twice means no checking at all | |
220 cli_opts.no_hostkey_check = 1; | |
221 } | |
216 cli_opts.always_accept_key = 1; | 222 cli_opts.always_accept_key = 1; |
217 break; | 223 break; |
218 case 'p': /* remoteport */ | 224 case 'p': /* remoteport */ |
219 next = &cli_opts.remoteport; | 225 next = &cli_opts.remoteport; |
220 break; | 226 break; |
459 multihop_passthrough_args() { | 465 multihop_passthrough_args() { |
460 char *ret; | 466 char *ret; |
461 int total; | 467 int total; |
462 unsigned int len = 0; | 468 unsigned int len = 0; |
463 m_list_elem *iter; | 469 m_list_elem *iter; |
464 /* Fill out -i and -W options that make sense for all | 470 /* Fill out -i, -y, -W options that make sense for all |
465 * the intermediate processes */ | 471 * the intermediate processes */ |
466 for (iter = cli_opts.privkeys->first; iter; iter = iter->next) | 472 for (iter = cli_opts.privkeys->first; iter; iter = iter->next) |
467 { | 473 { |
468 sign_key * key = (sign_key*)iter->item; | 474 sign_key * key = (sign_key*)iter->item; |
469 len += 3 + strlen(key->filename); | 475 len += 3 + strlen(key->filename); |
470 } | 476 } |
471 len += 20; // space for -W <size>, terminator. | 477 len += 30; // space for -W <size>, terminator. |
472 ret = m_malloc(len); | 478 ret = m_malloc(len); |
473 total = 0; | 479 total = 0; |
474 | 480 |
481 if (cli_opts.no_hostkey_check) | |
482 { | |
483 int written = snprintf(ret+total, len-total, "-y -y "); | |
484 total += written; | |
485 } | |
486 else if (cli_opts.always_accept_key) | |
487 { | |
488 int written = snprintf(ret+total, len-total, "-y "); | |
489 total += written; | |
490 } | |
491 | |
475 if (opts.recv_window != DEFAULT_RECV_WINDOW) | 492 if (opts.recv_window != DEFAULT_RECV_WINDOW) |
476 { | 493 { |
477 int written = snprintf(ret+total, len-total, "-W %d", opts.recv_window); | 494 int written = snprintf(ret+total, len-total, "-W %d ", opts.recv_window); |
478 total += written; | 495 total += written; |
479 } | 496 } |
480 | 497 |
481 for (iter = cli_opts.privkeys->first; iter; iter = iter->next) | 498 for (iter = cli_opts.privkeys->first; iter; iter = iter->next) |
482 { | 499 { |
483 sign_key * key = (sign_key*)iter->item; | 500 sign_key * key = (sign_key*)iter->item; |
484 const size_t size = len - total; | 501 const size_t size = len - total; |
485 int written = snprintf(ret+total, size, "-i %s", key->filename); | 502 int written = snprintf(ret+total, size, "-i %s ", key->filename); |
486 dropbear_assert((unsigned int)written < size); | 503 dropbear_assert((unsigned int)written < size); |
487 total += written; | 504 total += written; |
505 } | |
506 | |
507 /* if args where passed, total will be not zero, and it will have a space at the end, so remove that */ | |
508 if (total > 0) | |
509 { | |
510 total--; | |
488 } | 511 } |
489 | 512 |
490 return ret; | 513 return ret; |
491 } | 514 } |
492 | 515 |