]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
remote: push logic for default netcat binary into common helper
authorDaniel P. Berrangé <berrange@redhat.com>
Tue, 21 Jul 2020 11:15:57 +0000 (12:15 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Wed, 9 Sep 2020 15:46:22 +0000 (16:46 +0100)
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é <berrange@redhat.com>
src/remote/remote_driver.c
src/rpc/virnetclient.c

index 8c055e03478ac60d4b2e59f9bbbb746dd696e906..5755eecf54c1a37abf422dbdab3663f83026ee5d 100644 (file)
@@ -1225,7 +1225,7 @@ doRemoteOpen(virConnectPtr conn,
                                                 username,
                                                 !tty,
                                                 !verify,
-                                                netcat ? netcat : "nc",
+                                                netcat,
                                                 keyfile,
                                                 sockname)))
             goto failed;
index 9c76eaca5ec5944eb25c962b9086135badb8243c..bb8cbe3cb53564f205f664cf1b55190982f49f81 100644 (file)
@@ -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);