mirror of
https://github.com/moparisthebest/curl
synced 2024-12-24 17:18:48 -05:00
curl: show better error message when no homedir is found
Reported-by: Vlastimil Ovčáčík Fixes #4644 Closes #4665
This commit is contained in:
parent
0092b6bf8a
commit
7dffc2b46f
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#define WARN_PREFIX "Warning: "
|
#define WARN_PREFIX "Warning: "
|
||||||
#define NOTE_PREFIX "Note: "
|
#define NOTE_PREFIX "Note: "
|
||||||
|
#define ERROR_PREFIX "curl: "
|
||||||
|
|
||||||
static void voutf(struct GlobalConfig *config,
|
static void voutf(struct GlobalConfig *config,
|
||||||
const char *prefix,
|
const char *prefix,
|
||||||
@ -122,3 +123,16 @@ void helpf(FILE *errors, const char *fmt, ...)
|
|||||||
#endif
|
#endif
|
||||||
"for more information\n");
|
"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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
void warnf(struct GlobalConfig *config, const char *fmt, ...);
|
void warnf(struct GlobalConfig *config, const char *fmt, ...);
|
||||||
void notef(struct GlobalConfig *config, const char *fmt, ...);
|
void notef(struct GlobalConfig *config, const char *fmt, ...);
|
||||||
|
|
||||||
void helpf(FILE *errors, const char *fmt, ...);
|
void helpf(FILE *errors, const char *fmt, ...);
|
||||||
|
void errorf(struct GlobalConfig *config, const char *fmt, ...);
|
||||||
|
|
||||||
#endif /* HEADER_CURL_TOOL_MSGS_H */
|
#endif /* HEADER_CURL_TOOL_MSGS_H */
|
||||||
|
@ -1615,7 +1615,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
|
|||||||
if(!config->insecure_ok) {
|
if(!config->insecure_ok) {
|
||||||
char *home;
|
char *home;
|
||||||
char *file;
|
char *file;
|
||||||
result = CURLE_OUT_OF_MEMORY;
|
result = CURLE_FAILED_INIT;
|
||||||
home = homedir();
|
home = homedir();
|
||||||
if(home) {
|
if(home) {
|
||||||
file = aprintf("%s/.ssh/known_hosts", home);
|
file = aprintf("%s/.ssh/known_hosts", home);
|
||||||
@ -1629,6 +1629,9 @@ static CURLcode single_transfer(struct GlobalConfig *global,
|
|||||||
}
|
}
|
||||||
Curl_safefree(home);
|
Curl_safefree(home);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
errorf(global, "Failed to figure out user's home dir!");
|
||||||
|
}
|
||||||
if(result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user