changeset 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 cd02449b709c
files cli-runopts.c
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/cli-runopts.c	Mon Sep 22 14:13:44 2008 +0000
+++ b/cli-runopts.c	Mon Sep 22 15:47:35 2008 +0000
@@ -412,7 +412,20 @@
 	char *last_hop = NULL;;
 	char *remainder = NULL;
 
-	userhostarg = m_strdup(orighostarg);
+	/* both scp and rsync parse a user@host argument
+	 * and turn it into "-l user host". This breaks
+	 * for our multihop syntax, so we suture it back together.
+	 * This will break usernames that have both '@' and ',' in them,
+	 * though that should be fairly uncommon. */
+	if (cli_opts.username 
+			&& strchr(cli_opts.username, ',') 
+			&& strchr(cli_opts.username, '@')) {
+		unsigned int len = strlen(orighostarg) + strlen(cli_opts.username) + 2;
+		userhostarg = m_malloc(len);
+		snprintf(userhostarg, len, "%s@%s", cli_opts.username, orighostarg);
+	} else {
+		userhostarg = m_strdup(orighostarg);
+	}
 
 	last_hop = strrchr(userhostarg, ',');
 	if (last_hop) {