File 003-Fix-ssh-tunnel-with-non-POSIX-remote-shells.patch of Package virt-viewer
Subject: src: Fix ssh tunnel with non-POSIX remote shells
From: Martin Kletzander nert.pinx@gmail.com Fri Jan 27 10:42:26 2023 +0100
Date: Fri Jan 27 10:51:00 2023 +0100:
Git: 0a6155ca13cbb9f5f9ecf4210439a207807cbc96
The command depends on POSIX-compatible shell being the default shell on
the remote side of SSH, but that might not be the case. To make sure
the command gets parsed correctly this commit encloses it in extra
single quotes (to avoid it being parsed by the remote shell) and passes
that string as a parameter to `sh -c`.
Signed-off-by: Martin Kletzander <nert.pinx@gmail.com>
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index b977b7b..abc6f48 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -847,7 +847,7 @@ virt_viewer_app_open_tunnel_ssh(const char *sshhost,
}
cmd[n++] = sshhost;
- cat = g_string_new("if (command -v socat) >/dev/null 2>&1");
+ cat = g_string_new("sh -c 'if (command -v socat) >/dev/null 2>&1");
g_string_append(cat, "; then socat - ");
if (port) {
@@ -868,7 +868,7 @@ virt_viewer_app_open_tunnel_ssh(const char *sshhost,
else
g_string_append_printf(cat, "-U %s", unixsock);
- g_string_append(cat, "; fi");
+ g_string_append(cat, "; fi'");
cmd[n++] = cat->str;
cmd[n++] = NULL;