]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
remote: do not check for an existing config dir
authorPino Toscano <ptoscano@redhat.com>
Tue, 10 Jan 2017 18:43:20 +0000 (19:43 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 11 Jan 2017 12:38:04 +0000 (13:38 +0100)
When composing the path to the default known_hosts file (for the libssh
and libssh2 drivers), do not check whether the configuration directory
(determined by virGetUserConfigDirectory()) exists: both the drivers can
handle non-existing files, and are able to create them (and their
directories) in that case.

This adds a small behaviour change: before, the key for an unknown host,
and manually accepted, was saved only if the configuration directory
existed -- a bit incoherent behaviour though.

src/rpc/virnetclient.c

index 9c781e37139c71c426fedbcab732c5a0bd5ef39c..5174614df7012b61ccadb7c62af61f3e18bf41df 100644 (file)
@@ -462,11 +462,9 @@ virNetClientPtr virNetClientNewLibSSH2(const char *host,
     } else {
         confdir = virGetUserConfigDirectory();
         if (confdir) {
-            if (virFileExists(confdir)) {
-                virBufferAsprintf(&buf, "%s/known_hosts", confdir);
-                if (!(knownhosts = virBufferContentAndReset(&buf)))
-                    goto no_memory;
-            }
+            virBufferAsprintf(&buf, "%s/known_hosts", confdir);
+            if (!(knownhosts = virBufferContentAndReset(&buf)))
+                goto no_memory;
         }
     }
 
@@ -573,10 +571,8 @@ virNetClientPtr virNetClientNewLibssh(const char *host,
     } else {
         confdir = virGetUserConfigDirectory();
         if (confdir) {
-            if (virFileExists(confdir)) {
-                if (virAsprintf(&knownhosts, "%s/known_hosts", confdir) < 0)
-                    goto cleanup;
-            }
+            if (virAsprintf(&knownhosts, "%s/known_hosts", confdir) < 0)
+                goto cleanup;
         }
     }