virt-v2v/0027-it-ssh-Double-quote-ssh-command-which-tests-remote-f.patch

39 lines
1.6 KiB
Diff
Raw Normal View History

From 450e6c712b65eed91427fb9ac8c8e19b4e8eb9ad Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 2 Oct 2023 10:00:10 +0100
Subject: [PATCH] -it ssh: Double quote ssh command which tests remote file
exists
Double quoting was removed in
commit e2af12ba69c4463bb73d30db63290a887cdd41eb ("input: -i vmx:
Remove support for openssh scp < 8.8", Nov 2021). However it should
only have been removed from scp commands, not for this ssh command
where it is still required.
See: https://github.com/libguestfs/virt-v2v/issues/35
Thanks: Laszlo Ersek for diagnosis and suggesting the fix
Reported-by: Bill Sanders
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 22c5b98ab78c734b478c26e14ee62e2a065aaa0c)
---
input/parse_domain_from_vmx.ml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/input/parse_domain_from_vmx.ml b/input/parse_domain_from_vmx.ml
index 15ee093f..2e75e785 100644
--- a/input/parse_domain_from_vmx.ml
+++ b/input/parse_domain_from_vmx.ml
@@ -97,7 +97,11 @@ let remote_file_exists uri path =
| None -> ""
| Some user -> quote user ^ "@")
(quote (server_of_uri uri))
- (quote path) in
+ (* Double quoting is necessary for 'ssh', first to protect
+ * from the local shell, second to protect from the remote
+ * shell. https://github.com/libguestfs/virt-v2v/issues/35#issuecomment-1741730963
+ *)
+ (quote (quote path)) in
if verbose () then
eprintf "%s\n%!" cmd;
Sys.command cmd = 0