mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-17 22:10:41 +01:00
core bugfix: segfault after configuration errors
rsyslog will segfault on startup if a) the local machine's hostname is set to a non-FQDN name b) the getaddrinfo() system call fails This scenario is higly unlikely, but may exist especially with provisioned VMs which may not properly be able to do name queries on startup (seen for example on AWS). This patch fixes the situation and also provides more robustness for very early startup error messages when some of the error-reporting subsystem is not yet properly initialized. Note that under these circumstances, errors may only show up on stderr. closes https://github.com/rsyslog/rsyslog/issues/1573
This commit is contained in:
parent
36825174e1
commit
6d25833980
@ -1194,8 +1194,9 @@ getLocalHostname(uchar **ppName)
|
||||
/* If we get one of errors above, network is probably
|
||||
* not working yet, so we fall back to local hostname below
|
||||
*/
|
||||
dbgprintf("getaddrinfo: %s\n", gai_strerror(error));
|
||||
ABORT_FINALIZE(RS_RET_IO_ERROR);
|
||||
LogError(0, RS_RET_ERR, "getaddrinfo failed obtaining local "
|
||||
"hostname - using '%s' instead; error: %s",
|
||||
hnbuf, gai_strerror(error));
|
||||
}
|
||||
if (res != NULL) {
|
||||
/* When AI_CANONNAME is set first member of res linked-list */
|
||||
|
||||
@ -133,7 +133,13 @@ propConstructFinalize(prop_t __attribute__((unused)) *pThis)
|
||||
*/
|
||||
static rsRetVal AddRef(prop_t *pThis)
|
||||
{
|
||||
if(pThis == NULL) {
|
||||
DBGPRINTF("prop/AddRef is passed a NULL ptr - ignoring it "
|
||||
"- further problems may occur\n");
|
||||
FINALIZE;
|
||||
}
|
||||
ATOMIC_INC(&pThis->iRefCount, &pThis->mutRefCount);
|
||||
finalize_it:
|
||||
return RS_RET_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -933,9 +933,11 @@ logmsgInternal(int iErr, const syslog_pri_t pri, const uchar *const msg, int fla
|
||||
* permits us to process unmodified config files which otherwise contain a
|
||||
* supressor statement.
|
||||
*/
|
||||
if(((Debug == DEBUG_FULL || !doFork) && ourConf->globals.bErrMsgToStderr) || iConfigVerify) {
|
||||
int emit_to_stderr = (ourConf == NULL) ? 1 : ourConf->globals.bErrMsgToStderr;
|
||||
if(((Debug == DEBUG_FULL || !doFork) && emit_to_stderr) || iConfigVerify) {
|
||||
if(pri2sev(pri) == LOG_ERR)
|
||||
fprintf(stderr, "rsyslogd: %s\n", (bufModMsg == NULL) ? (char*)msg : bufModMsg);
|
||||
fprintf(stderr, "rsyslogd: %s\n",
|
||||
(bufModMsg == NULL) ? (char*)msg : bufModMsg);
|
||||
}
|
||||
|
||||
finalize_it:
|
||||
@ -1249,18 +1251,17 @@ initAll(int argc, char **argv)
|
||||
|
||||
/* doing some core initializations */
|
||||
|
||||
/* get our host and domain names - we need to do this early as we may emit
|
||||
* error log messages, which need the correct hostname. -- rgerhards, 2008-04-04
|
||||
*/
|
||||
queryLocalHostname();
|
||||
|
||||
/* initialize the objects */
|
||||
if((iRet = modInitIminternal()) != RS_RET_OK) {
|
||||
fprintf(stderr, "fatal error: could not initialize errbuf object (error code %d).\n",
|
||||
iRet);
|
||||
exit(1); /* "good" exit, leaving at init for fatal error */
|
||||
}
|
||||
|
||||
/* get our host and domain names - we need to do this early as we may emit
|
||||
* error log messages, which need the correct hostname. -- rgerhards, 2008-04-04
|
||||
* But we need to have imInternal up first!
|
||||
*/
|
||||
queryLocalHostname();
|
||||
|
||||
/* END core initializations - we now come back to carrying out command line options*/
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user