summaryrefslogtreecommitdiffhomepage
path: root/cli-runopts.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2013-05-21 12:09:35 +0800
committerMatt Johnston <matt@ucc.asn.au>2013-05-21 12:09:35 +0800
commit04518e9e801ee57bd6d4caab470da8dc0ec98fd7 (patch)
tree5e46adedc7cd70e6f7b0547a200544cbcf80b96b /cli-runopts.c
parent41f531ceafc86507c82847f44f9c9e126d798c48 (diff)
parenta57947c513a53e77de0b2eaa67ca6404f444a29f (diff)
merge in HEAD
--HG-- branch : ecc
Diffstat (limited to 'cli-runopts.c')
-rw-r--r--cli-runopts.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/cli-runopts.c b/cli-runopts.c
index 5ddcc21..91a2f42 100644
--- a/cli-runopts.c
+++ b/cli-runopts.c
@@ -62,6 +62,7 @@ static void printhelp() {
"-N Don't run a remote command\n"
"-f Run in background after auth\n"
"-y Always accept remote host key if unknown\n"
+ "-y -y Don't perform any remote host key checking (caution)\n"
"-s Request a subsystem (use by external sftp)\n"
#ifdef ENABLE_CLI_PUBKEY_AUTH
"-i <identityfile> (multiple allowed)\n"
@@ -130,6 +131,7 @@ void cli_getopts(int argc, char ** argv) {
cli_opts.backgrounded = 0;
cli_opts.wantpty = 9; /* 9 means "it hasn't been touched", gets set later */
cli_opts.always_accept_key = 0;
+ cli_opts.no_hostkey_check = 0;
cli_opts.is_subsystem = 0;
#ifdef ENABLE_CLI_PUBKEY_AUTH
cli_opts.privkeys = list_new();
@@ -213,6 +215,10 @@ void cli_getopts(int argc, char ** argv) {
switch (argv[i][1]) {
case 'y': /* always accept the remote hostkey */
+ if (cli_opts.always_accept_key) {
+ // twice means no checking at all
+ cli_opts.no_hostkey_check = 1;
+ }
cli_opts.always_accept_key = 1;
break;
case 'p': /* remoteport */
@@ -461,20 +467,31 @@ multihop_passthrough_args() {
int total;
unsigned int len = 0;
m_list_elem *iter;
- /* Fill out -i and -W options that make sense for all
+ /* Fill out -i, -y, -W options that make sense for all
* the intermediate processes */
for (iter = cli_opts.privkeys->first; iter; iter = iter->next)
{
sign_key * key = (sign_key*)iter->item;
len += 3 + strlen(key->filename);
}
- len += 20; // space for -W <size>, terminator.
+ len += 30; // space for -W <size>, terminator.
ret = m_malloc(len);
total = 0;
+ if (cli_opts.no_hostkey_check)
+ {
+ int written = snprintf(ret+total, len-total, "-y -y ");
+ total += written;
+ }
+ else if (cli_opts.always_accept_key)
+ {
+ int written = snprintf(ret+total, len-total, "-y ");
+ total += written;
+ }
+
if (opts.recv_window != DEFAULT_RECV_WINDOW)
{
- int written = snprintf(ret+total, len-total, "-W %d", opts.recv_window);
+ int written = snprintf(ret+total, len-total, "-W %d ", opts.recv_window);
total += written;
}
@@ -482,11 +499,17 @@ multihop_passthrough_args() {
{
sign_key * key = (sign_key*)iter->item;
const size_t size = len - total;
- int written = snprintf(ret+total, size, "-i %s", key->filename);
+ int written = snprintf(ret+total, size, "-i %s ", key->filename);
dropbear_assert((unsigned int)written < size);
total += written;
}
+ /* if args were passed, total will be not zero, and it will have a space at the end, so remove that */
+ if (total > 0)
+ {
+ total--;
+ }
+
return ret;
}
@@ -587,7 +610,11 @@ static void parse_hostname(const char* orighostarg) {
cli_opts.username = m_strdup(cli_opts.own_user);
}
- port = strchr(cli_opts.remotehost, '/');
+ port = strchr(cli_opts.remotehost, '%');
+ if (!port) {
+ // legacy separator
+ port = strchr(cli_opts.remotehost, '/');
+ }
if (port) {
*port = '\0';
cli_opts.remoteport = port+1;