Mercurial > dropbear
comparison cli-runopts.c @ 494:66eac4631d88
- Work around rsync and scp parsing and modifying the user@host argument,
which break's dbclient's multihop syntax
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 22 Sep 2008 15:47:35 +0000 |
parents | b956d6151600 |
children | ae600f1eef81 |
comparison
equal
deleted
inserted
replaced
492:b956d6151600 | 494:66eac4631d88 |
---|---|
410 static void parse_multihop_hostname(const char* orighostarg, const char* argv0) { | 410 static void parse_multihop_hostname(const char* orighostarg, const char* argv0) { |
411 char *userhostarg = NULL; | 411 char *userhostarg = NULL; |
412 char *last_hop = NULL;; | 412 char *last_hop = NULL;; |
413 char *remainder = NULL; | 413 char *remainder = NULL; |
414 | 414 |
415 userhostarg = m_strdup(orighostarg); | 415 /* both scp and rsync parse a user@host argument |
416 * and turn it into "-l user host". This breaks | |
417 * for our multihop syntax, so we suture it back together. | |
418 * This will break usernames that have both '@' and ',' in them, | |
419 * though that should be fairly uncommon. */ | |
420 if (cli_opts.username | |
421 && strchr(cli_opts.username, ',') | |
422 && strchr(cli_opts.username, '@')) { | |
423 unsigned int len = strlen(orighostarg) + strlen(cli_opts.username) + 2; | |
424 userhostarg = m_malloc(len); | |
425 snprintf(userhostarg, len, "%s@%s", cli_opts.username, orighostarg); | |
426 } else { | |
427 userhostarg = m_strdup(orighostarg); | |
428 } | |
416 | 429 |
417 last_hop = strrchr(userhostarg, ','); | 430 last_hop = strrchr(userhostarg, ','); |
418 if (last_hop) { | 431 if (last_hop) { |
419 if (last_hop == userhostarg) { | 432 if (last_hop == userhostarg) { |
420 dropbear_exit("Bad multi-hop hostnames"); | 433 dropbear_exit("Bad multi-hop hostnames"); |