From: Daniel Stenberg Date: Tue, 29 Oct 2024 09:15:53 +0000 (+0100) Subject: curl/config2setopts: move SSH related options into same block X-Git-Tag: curl-8_11_0~32 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a70f5bc4b50799701924afc46b24e53841769158;p=thirdparty%2Fcurl.git curl/config2setopts: move SSH related options into same block Move the code setting SSH specific libcurl options into the same block to avoid having a separate almost identical condition later. Closes #15444 --- diff --git a/src/tool_operate.c b/src/tool_operate.c index 65485c8968..a1212c9dde 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -1169,6 +1169,22 @@ static CURLcode config2setopts(struct GlobalConfig *global, /* new in libcurl 7.56.0 */ if(config->ssh_compression) my_setopt(curl, CURLOPT_SSH_COMPRESSION, 1L); + + if(!config->insecure_ok) { + 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) + return result; + } + else + warnf(global, "Couldn't find a known_hosts file"); + } } if(config->cacert) @@ -1344,23 +1360,6 @@ static CURLcode config2setopts(struct GlobalConfig *global, if(config->path_as_is) my_setopt(curl, CURLOPT_PATH_AS_IS, 1L); - if((use_proto == proto_scp || use_proto == proto_sftp) && - !config->insecure_ok) { - 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) - return result; - } - else - warnf(global, "Couldn't find a known_hosts file"); - } - if(config->no_body || config->remote_time) { /* no body or use remote time */ my_setopt(curl, CURLOPT_FILETIME, 1L);