diff options
Diffstat (limited to 'src/tool_operate.c')
-rw-r--r-- | src/tool_operate.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c index b9183c22a..d648dc054 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -63,7 +63,7 @@ #include "tool_filetime.h" #include "tool_getparam.h" #include "tool_helpers.h" -#include "tool_homedir.h" +#include "tool_findfile.h" #include "tool_libinfo.h" #include "tool_main.h" #include "tool_msgs.h" @@ -1716,23 +1716,19 @@ static CURLcode single_transfer(struct GlobalConfig *global, if((use_proto & (CURLPROTO_SCP|CURLPROTO_SFTP)) && !config->insecure_ok) { - char *home = homedir(NULL); - if(home) { - char *file = aprintf("%s/.ssh/known_hosts", home); - if(file) { - /* new in curl 7.19.6 */ - result = res_setopt_str(curl, CURLOPT_SSH_KNOWNHOSTS, file); - curl_free(file); - if(result == CURLE_UNKNOWN_OPTION) - /* libssh2 version older than 1.1.1 */ - result = CURLE_OK; - } - Curl_safefree(home); + char *known = findfile(".ssh/known_hosts", FALSE); + if(known) { + /* new in curl 7.19.6 */ + result = res_setopt_str(curl, CURLOPT_SSH_KNOWNHOSTS, known); + curl_free(known); + if(result == CURLE_UNKNOWN_OPTION) + /* libssh2 version older than 1.1.1 */ + result = CURLE_OK; if(result) break; } else - warnf(global, "No home dir, couldn't find known_hosts file!"); + warnf(global, "Couldn't find a known_hosts file!"); } if(config->no_body || config->remote_time) { |