summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-12-02 12:00:41 +0100
committerDaniel Stenberg <daniel@haxx.se>2019-12-02 12:00:41 +0100
commit5fdbda2f6a82eab92df13e87857d5c9ace9c778c (patch)
tree741fb62353ce2b63e05ff35a94576f6a51e768a2
parentd4a1862719d7e16125364a62cb6b090ccd866fa7 (diff)
downloadcurl-bagder/no-homedir-error.tar.gz
curl: show better error message when no homedir is foundbagder/no-homedir-error
Reported-by: Vlastimil Ovčáčík Fixes #4644
-rw-r--r--src/tool_msgs.c14
-rw-r--r--src/tool_msgs.h2
-rw-r--r--src/tool_operate.c5
3 files changed, 19 insertions, 2 deletions
diff --git a/src/tool_msgs.c b/src/tool_msgs.c
index 48c724940..c0e85aee6 100644
--- a/src/tool_msgs.c
+++ b/src/tool_msgs.c
@@ -32,6 +32,7 @@
#define WARN_PREFIX "Warning: "
#define NOTE_PREFIX "Note: "
+#define ERROR_PREFIX "curl: "
static void voutf(struct GlobalConfig *config,
const char *prefix,
@@ -122,3 +123,16 @@ void helpf(FILE *errors, const char *fmt, ...)
#endif
"for more information\n");
}
+
+/*
+ * Emit error message on error stream if not muted.
+ */
+void errorf(struct GlobalConfig *config, const char *fmt, ...)
+{
+ if(!config->mute) {
+ va_list ap;
+ va_start(ap, fmt);
+ voutf(config, ERROR_PREFIX, fmt, ap);
+ va_end(ap);
+ }
+}
diff --git a/src/tool_msgs.h b/src/tool_msgs.h
index bd8480d30..2c4afd180 100644
--- a/src/tool_msgs.h
+++ b/src/tool_msgs.h
@@ -25,7 +25,7 @@
void warnf(struct GlobalConfig *config, const char *fmt, ...);
void notef(struct GlobalConfig *config, const char *fmt, ...);
-
void helpf(FILE *errors, const char *fmt, ...);
+void errorf(struct GlobalConfig *config, const char *fmt, ...);
#endif /* HEADER_CURL_TOOL_MSGS_H */
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 23971f112..ab3a7f1a0 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -1615,7 +1615,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
if(!config->insecure_ok) {
char *home;
char *file;
- result = CURLE_OUT_OF_MEMORY;
+ result = CURLE_FAILED_INIT;
home = homedir();
if(home) {
file = aprintf("%s/.ssh/known_hosts", home);
@@ -1629,6 +1629,9 @@ static CURLcode single_transfer(struct GlobalConfig *global,
}
Curl_safefree(home);
}
+ else {
+ errorf(global, "Failed to figure out user's home dir!");
+ }
if(result)
break;
}