New match which mangles the argv correctly.

Adrian
-- 
Email: [email protected]  -*-  GPG key available on public key servers
Debian GNU/Linux - the maintainable distribution   -*-  www.debian.org
--- ../a/libvirt-0.5.1/src/remote_internal.c	2008-12-04 12:51:40.000000000 +0000
+++ src/remote_internal.c	2009-01-30 17:40:37.000000000 +0000
@@ -353,9 +353,6 @@
     } else if (transport == trans_tcp) {
         port = strdup (LIBVIRTD_TCP_PORT);
         if (!port) goto out_of_memory;
-    } else if (transport == trans_ssh) {
-        port = strdup ("22");
-        if (!port) goto out_of_memory;
     } else
         port = NULL;           /* Port not used for unix, ext. */
 
@@ -644,8 +641,9 @@
     }
 
     case trans_ssh: {
-        int j, nr_args = 8;
+        int j, nr_args = 6;
 
+        if (port) nr_args += 2; /* For -p port */
         if (username) nr_args += 2; /* For -l username */
         if (no_tty) nr_args += 5;   /* For -T -o BatchMode=yes -e none */
 
@@ -654,14 +652,16 @@
             goto out_of_memory;
 
         // Generate the final command argv[] array.
-        //   ssh -p $port [-l $username] $hostname $netcat -U $sockname [NULL]
+        //   ssh [-p $port] [-l $username] $hostname $netcat -U $sockname [NULL]
         if (VIR_ALLOC_N(cmd_argv, nr_args) < 0)
             goto out_of_memory;
 
         j = 0;
         cmd_argv[j++] = strdup (command);
-        cmd_argv[j++] = strdup ("-p");
-        cmd_argv[j++] = strdup (port);
+        if (port) {
+            cmd_argv[j++] = strdup ("-p");
+            cmd_argv[j++] = strdup (port);
+        }
         if (username) {
             cmd_argv[j++] = strdup ("-l");
             cmd_argv[j++] = strdup (username);

Reply via email to