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.
} 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;
}
}
} 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;
}
}