diff 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
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) {