]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl: only warn not fail, if not finding the home dir
authorDaniel Stenberg <daniel@haxx.se>
Thu, 12 Nov 2020 23:37:21 +0000 (00:37 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 13 Nov 2020 10:32:46 +0000 (11:32 +0100)
... as there's no good reason to error out completely.

Reported-by: Andreas Fischer
Fixes #6200
Closes #6201

src/tool_operate.c

index bc9dc058b97606cf3fc7ad382b19ad702b8fc0c2..90522e1e947c25bca097dad7987f6021e13e733e 100644 (file)
@@ -1711,30 +1711,25 @@ static CURLcode single_transfer(struct GlobalConfig *global,
         if(config->path_as_is)
           my_setopt(curl, CURLOPT_PATH_AS_IS, 1L);
 
-        if(built_in_protos & (CURLPROTO_SCP|CURLPROTO_SFTP)) {
-          if(!config->insecure_ok) {
-            char *home;
-            char *file;
-            result = CURLE_FAILED_INIT;
-            home = homedir(NULL);
-            if(home) {
-              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);
-            }
-            else {
-              errorf(global, "Failed to figure out user's home dir!");
+        if((built_in_protos & (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);
             if(result)
               break;
           }
+          else
+            warnf(global, "No home dir, couldn't find known_hosts file!");
         }
 
         if(config->no_body || config->remote_time) {