Skip to content

Commit

Permalink
curl/config2setopts: move SSH related options into same block
Browse files Browse the repository at this point in the history
Move the code setting SSH specific libcurl options into the same block
to avoid having a separate almost identical condition later.

Closes #15444
  • Loading branch information
bagder committed Oct 29, 2024
1 parent 84f96e3 commit a70f5bc
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/tool_operate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a70f5bc

Please sign in to comment.