From: Pino Toscano Date: Tue, 10 Jan 2017 18:43:20 +0000 (+0100) Subject: remote: do not check for an existing config dir X-Git-Tag: v3.0.0-rc2~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a5de3fe2e72992cfb614fea2acb0335459ebdea;p=thirdparty%2Flibvirt.git remote: do not check for an existing config dir 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. --- diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 9c781e3713..5174614df7 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -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; } }