From 5cd80b04d918c001587ba262cc4e44cd7a16b198 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Tue, 21 Jul 2020 12:15:57 +0100 Subject: [PATCH] remote: push logic for default netcat binary into common helper MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We don't want to repeat the choice of default netcat binary setting in three different places. This will also make it possible to do better error reporting in the helper. Signed-off-by: Daniel P. Berrangé --- src/remote/remote_driver.c | 2 +- src/rpc/virnetclient.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 8c055e0347..5755eecf54 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -1225,7 +1225,7 @@ doRemoteOpen(virConnectPtr conn, username, !tty, !verify, - netcat ? netcat : "nc", + netcat, keyfile, sockname))) goto failed; diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 9c76eaca5e..bb8cbe3cb5 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -419,6 +419,9 @@ virNetClientSSHHelperCommand(const char *netcatPath, { g_autofree char *netcatPathSafe = virNetClientDoubleEscapeShell(netcatPath); + if (!netcatPath) + netcatPath = "nc"; + return g_strdup_printf( "sh -c " "'if '%s' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then " @@ -505,7 +508,6 @@ virNetClientPtr virNetClientNewLibSSH2(const char *host, DEFAULT_VALUE(host, "localhost"); DEFAULT_VALUE(port, "22"); DEFAULT_VALUE(username, "root"); - DEFAULT_VALUE(netcatPath, "nc"); DEFAULT_VALUE(knownHostsVerify, "normal"); command = virNetClientSSHHelperCommand(netcatPath, socketPath); @@ -566,7 +568,6 @@ virNetClientPtr virNetClientNewLibssh(const char *host, DEFAULT_VALUE(host, "localhost"); DEFAULT_VALUE(port, "22"); DEFAULT_VALUE(username, "root"); - DEFAULT_VALUE(netcatPath, "nc"); DEFAULT_VALUE(knownHostsVerify, "normal"); command = virNetClientSSHHelperCommand(netcatPath, socketPath); -- 2.47.2