diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-09-05 14:17:53 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-09-05 15:38:59 +0000 |
commit | 19ceccea15e712616b1c5a48339be10fcadba41b (patch) | |
tree | efb4ebd14cf8123bc6a20e5c7b2c3fc7351ca035 /morphlib/exts | |
parent | e062415af49f2439eff2a7702f83f1a9f6a8afe6 (diff) | |
download | morph-19ceccea15e712616b1c5a48339be10fcadba41b.tar.gz |
Fix shell quoting for ssh remote command lines
Found by Richard Maw.
Diffstat (limited to 'morphlib/exts')
-rwxr-xr-x | morphlib/exts/kvm.write | 8 | ||||
-rwxr-xr-x | morphlib/exts/virtualbox-ssh.write | 9 |
2 files changed, 11 insertions, 6 deletions
diff --git a/morphlib/exts/kvm.write b/morphlib/exts/kvm.write index 3e3b3eb1..16f188b5 100755 --- a/morphlib/exts/kvm.write +++ b/morphlib/exts/kvm.write @@ -94,11 +94,13 @@ class KvmPlusSshWriteExtension(morphlib.writeexts.WriteExtension): xfer_hole_path = morphlib.util.get_data_path('xfer-hole') recv_hole = morphlib.util.get_data('recv-hole') + ssh_remote_cmd = [ + 'sh', '-c', recv_hole, 'dummy-argv0', 'file', vm_path + ] + cliapp.runcmd( ['python', xfer_hole_path, raw_disk], - ['ssh', ssh_host, - 'sh', '-c', cliapp.shell_quote(recv_hole), - 'dummy-argv0', 'file', vm_path], + ['ssh', ssh_host] + map(cliapp.shell_quote, ssh_remote_cmd), stdout=None, stderr=None) def create_libvirt_guest(self, ssh_host, vm_name, vm_path, autostart): diff --git a/morphlib/exts/virtualbox-ssh.write b/morphlib/exts/virtualbox-ssh.write index 1aebe490..39ea8f86 100755 --- a/morphlib/exts/virtualbox-ssh.write +++ b/morphlib/exts/virtualbox-ssh.write @@ -107,11 +107,14 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension): xfer_hole_path = morphlib.util.get_data_path('xfer-hole') recv_hole = morphlib.util.get_data('recv-hole') + ssh_remote_cmd = [ + 'sh', '-c', recv_hole, + 'dummy-argv0', 'vbox', vdi_path, str(st.st_size), + ] + cliapp.runcmd( ['python', xfer_hole_path, raw_disk], - ['ssh', ssh_host, - 'sh', '-c', cliapp.shell_quote(recv_hole), - 'dummy-argv0', 'vbox', vdi_path, str(st.st_size)], + ['ssh', ssh_host] + map(cliapp.shell_quote, ssh_remote_cmd), stdout=None, stderr=None) def virtualbox_version(self, ssh_host): |