From 6a2778a3471a5d90af5c5a170eec63dddebd5e9d Mon Sep 17 00:00:00 2001 From: Qiumiao Zhang Date: Mon, 18 Sep 2023 21:54:37 +0800 Subject: [PATCH] outchannel: eleminate type cast for compatibility reasons Signed-off-by: Qiumiao Zhang (cherry picked from commit 6ed3260b1af1f04bc3b41d2ae3b353457fe63efc) --- ...Driver-Fix-memory-leaks-in-gtlsInitC.patch | 108 +++++------ ...prevent-pot.-segfault-when-switchung.patch | 114 ++++++------ ...ate-system-may-generate-invalid-json.patch | 130 +++++++------- ...gfix-using-uuid-msg-prop-can-deadloc.patch | 168 +++++++++--------- ...journal-add-second-fallback-to-_COMM.patch | 76 ++++---- ...valid-status-handling-at-called-prog.patch | 92 +++++----- ...nate-type-cast-for-compatibility-rea.patch | 74 ++++++++ rsyslog.spec | 9 +- 8 files changed, 426 insertions(+), 345 deletions(-) create mode 100644 backport-outchannel-eleminate-type-cast-for-compatibility-rea.patch diff --git a/backport-GNUTls-Driver-Fix-memory-leaks-in-gtlsInitC.patch b/backport-GNUTls-Driver-Fix-memory-leaks-in-gtlsInitC.patch index cc84204..0610703 100644 --- a/backport-GNUTls-Driver-Fix-memory-leaks-in-gtlsInitC.patch +++ b/backport-GNUTls-Driver-Fix-memory-leaks-in-gtlsInitC.patch @@ -1,54 +1,54 @@ -From 0f06a850ced79244774734ed525b289f2930d9c7 Mon Sep 17 00:00:00 2001 -From: Andre lorbach -Date: Thu, 11 May 2023 16:49:11 +0200 -Subject: [PATCH] [backport] GNUTls Driver: Fix memory leaks in gtlsInitCred - -Missing CA Certificate or multiple Connections caused -a memory leak in pThis->xcred as it was allocated each time in -gtlsInitCred by gnutls_certificate_allocate_credentials - -closes: https://github.com/rsyslog/rsyslog/issues/5135 - ---- - -Conflict:NA -Type:bugfix -Reference:https://github.com/rsyslog/rsyslog/commit/3401d687d2d5f9556165b53be79fbe4dc49b8c79 - ---- ---- - runtime/nsd_gtls.c | 10 +++++++++- - 1 file changed, 9 insertions(+), 1 deletion(-) - -diff --git a/runtime/nsd_gtls.c b/runtime/nsd_gtls.c -index e003d85d3..91cffb500 100644 ---- a/runtime/nsd_gtls.c -+++ b/runtime/nsd_gtls.c -@@ -711,7 +711,10 @@ gtlsInitCred(nsd_gtls_t *const pThis ) - DEFiRet; - - /* X509 stuff */ -- CHKgnutls(gnutls_certificate_allocate_credentials(&pThis->xcred)); -+ if (pThis->xcred == NULL) { -+ /* Allocate only ONCE */ -+ CHKgnutls(gnutls_certificate_allocate_credentials(&pThis->xcred)); -+ } - - /* sets the trusted cas file */ - cafile = (pThis->pszCAFile == NULL) ? glbl.GetDfltNetstrmDrvrCAF(runConf) : pThis->pszCAFile; -@@ -2277,7 +2280,12 @@ finalize_it: - if(pThis->bHaveSess) { - gnutls_deinit(pThis->sess); - pThis->bHaveSess = 0; -+ /* Free memory using gnutls api first*/ -+ gnutls_certificate_free_credentials(pThis->xcred); - pThis->xcred = NULL; -+ /* Free other memory */ -+ free(pThis->pszConnectHost); -+ pThis->pszConnectHost = NULL; - } - } - --- -2.33.0 - +From 0f06a850ced79244774734ed525b289f2930d9c7 Mon Sep 17 00:00:00 2001 +From: Andre lorbach +Date: Thu, 11 May 2023 16:49:11 +0200 +Subject: [PATCH] [backport] GNUTls Driver: Fix memory leaks in gtlsInitCred + +Missing CA Certificate or multiple Connections caused +a memory leak in pThis->xcred as it was allocated each time in +gtlsInitCred by gnutls_certificate_allocate_credentials + +closes: https://github.com/rsyslog/rsyslog/issues/5135 + +--- + +Conflict:NA +Type:bugfix +Reference:https://github.com/rsyslog/rsyslog/commit/3401d687d2d5f9556165b53be79fbe4dc49b8c79 + +--- +--- + runtime/nsd_gtls.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/runtime/nsd_gtls.c b/runtime/nsd_gtls.c +index e003d85d3..91cffb500 100644 +--- a/runtime/nsd_gtls.c ++++ b/runtime/nsd_gtls.c +@@ -711,7 +711,10 @@ gtlsInitCred(nsd_gtls_t *const pThis ) + DEFiRet; + + /* X509 stuff */ +- CHKgnutls(gnutls_certificate_allocate_credentials(&pThis->xcred)); ++ if (pThis->xcred == NULL) { ++ /* Allocate only ONCE */ ++ CHKgnutls(gnutls_certificate_allocate_credentials(&pThis->xcred)); ++ } + + /* sets the trusted cas file */ + cafile = (pThis->pszCAFile == NULL) ? glbl.GetDfltNetstrmDrvrCAF(runConf) : pThis->pszCAFile; +@@ -2277,7 +2280,12 @@ finalize_it: + if(pThis->bHaveSess) { + gnutls_deinit(pThis->sess); + pThis->bHaveSess = 0; ++ /* Free memory using gnutls api first*/ ++ gnutls_certificate_free_credentials(pThis->xcred); + pThis->xcred = NULL; ++ /* Free other memory */ ++ free(pThis->pszConnectHost); ++ pThis->pszConnectHost = NULL; + } + } + +-- +2.33.0 + diff --git a/backport-bugfix-prevent-pot.-segfault-when-switchung.patch b/backport-bugfix-prevent-pot.-segfault-when-switchung.patch index ed493d1..016d8ec 100644 --- a/backport-bugfix-prevent-pot.-segfault-when-switchung.patch +++ b/backport-bugfix-prevent-pot.-segfault-when-switchung.patch @@ -1,57 +1,57 @@ -From 1807410d18519520ed813dd4b9d2b2d34e583415 Mon Sep 17 00:00:00 2001 -From: Rainer Gerhards -Date: Sun, 30 Oct 2022 18:43:26 +0100 -Subject: [PATCH] [backport] bugfix: prevent pot. segfault when switchung to - queue emergency mode - -When switching to Disk queue emergency mode, we destructed the in-memory -queue object. Practice has shown that this MAY cause races during -destruction which themselfs can lead to segfault. For that reason, we -now keep the disk queueu object. This will keep some ressources, -including disk space, allocated. But we prefer that over a segfault. -After all, it only happens after a serious queue error when we are -already at the edge of hard problems. - -see also: https://github.com/rsyslog/rsyslog/issues/4963 - ---- - -Conflict:NA -Type:bugfix -Reference:https://github.com/rsyslog/rsyslog/commit/eaac48d0d23afe0146454cd9f5004ddcb47cc81b - ---- ---- - runtime/queue.c | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - -diff --git a/runtime/queue.c b/runtime/queue.c -index b3fdd5101..856b4df25 100644 ---- a/runtime/queue.c -+++ b/runtime/queue.c -@@ -794,8 +794,12 @@ static rsRetVal qDelLinkedList(qqueue_t *pThis) - /* The following function is used to "save" ourself from being killed by - * a fatally failed disk queue. A fatal failure is, for example, if no - * data can be read or written. In that case, the disk support is disabled, -- * with all on-disk structures kept as-is as much as possible. Instead, the -- * queue is switched to direct mode, so that at least -+ * with all on-disk structures kept as-is as much as possible. However, -+ * we do not really stop or destruct the in-memory disk queue object. -+ * Practice has shown that this may cause races during destruction which -+ * themselfs can lead to segfault. So we prefer to was some ressources by -+ * keeping the queue active. -+ * Instead, the queue is switched to direct mode, so that at least - * some processing can happen. Of course, this may still have lots of - * undesired side-effects, but is probably better than aborting the - * syslogd. Note that this function *must* succeed in one way or another, as -@@ -808,7 +812,6 @@ queueSwitchToEmergencyMode(qqueue_t *pThis, rsRetVal initiatingError) - { - pThis->iQueueSize = 0; - pThis->nLogDeq = 0; -- qDestructDisk(pThis); /* free disk structures */ - - pThis->qType = QUEUETYPE_DIRECT; - pThis->qConstruct = qConstructDirect; --- -2.12.3 - +From 1807410d18519520ed813dd4b9d2b2d34e583415 Mon Sep 17 00:00:00 2001 +From: Rainer Gerhards +Date: Sun, 30 Oct 2022 18:43:26 +0100 +Subject: [PATCH] [backport] bugfix: prevent pot. segfault when switchung to + queue emergency mode + +When switching to Disk queue emergency mode, we destructed the in-memory +queue object. Practice has shown that this MAY cause races during +destruction which themselfs can lead to segfault. For that reason, we +now keep the disk queueu object. This will keep some ressources, +including disk space, allocated. But we prefer that over a segfault. +After all, it only happens after a serious queue error when we are +already at the edge of hard problems. + +see also: https://github.com/rsyslog/rsyslog/issues/4963 + +--- + +Conflict:NA +Type:bugfix +Reference:https://github.com/rsyslog/rsyslog/commit/eaac48d0d23afe0146454cd9f5004ddcb47cc81b + +--- +--- + runtime/queue.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/runtime/queue.c b/runtime/queue.c +index b3fdd5101..856b4df25 100644 +--- a/runtime/queue.c ++++ b/runtime/queue.c +@@ -794,8 +794,12 @@ static rsRetVal qDelLinkedList(qqueue_t *pThis) + /* The following function is used to "save" ourself from being killed by + * a fatally failed disk queue. A fatal failure is, for example, if no + * data can be read or written. In that case, the disk support is disabled, +- * with all on-disk structures kept as-is as much as possible. Instead, the +- * queue is switched to direct mode, so that at least ++ * with all on-disk structures kept as-is as much as possible. However, ++ * we do not really stop or destruct the in-memory disk queue object. ++ * Practice has shown that this may cause races during destruction which ++ * themselfs can lead to segfault. So we prefer to was some ressources by ++ * keeping the queue active. ++ * Instead, the queue is switched to direct mode, so that at least + * some processing can happen. Of course, this may still have lots of + * undesired side-effects, but is probably better than aborting the + * syslogd. Note that this function *must* succeed in one way or another, as +@@ -808,7 +812,6 @@ queueSwitchToEmergencyMode(qqueue_t *pThis, rsRetVal initiatingError) + { + pThis->iQueueSize = 0; + pThis->nLogDeq = 0; +- qDestructDisk(pThis); /* free disk structures */ + + pThis->qType = QUEUETYPE_DIRECT; + pThis->qConstruct = qConstructDirect; +-- +2.12.3 + diff --git a/backport-core-bugfix-template-system-may-generate-invalid-json.patch b/backport-core-bugfix-template-system-may-generate-invalid-json.patch index 27c9d93..4353c38 100644 --- a/backport-core-bugfix-template-system-may-generate-invalid-json.patch +++ b/backport-core-bugfix-template-system-may-generate-invalid-json.patch @@ -1,66 +1,66 @@ -From 246b8d8553b6880146d6c489a28cf4bacea8a199 Mon Sep 17 00:00:00 2001 -From: Rainer Gerhards -Date: Fri, 30 Dec 2022 17:13:17 +0100 -Subject: [PATCH] core bugfix: template system may generate invalid json - -When -- a list template -- is created with option.jsonf="on" -- and the last list element is a property with onEmpty="skip" -- and that property is actually empty -invalid JSON is generated. - -The JSON string in this case ends with ", " instead of "}\n". This -patch fixes the issue. - -closes https://github.com/rsyslog/rsyslog/issues/5050 ---- - -Conflict:NA -Reference:https://github.com/rsyslog/rsyslog/commit/246b8d8553b6880146d6c489a28cf4bacea8a199 ---- - template.c | 16 +++++++++++++--- - 1 file changed, 13 insertions(+), 3 deletions(-) - -diff --git a/template.c b/template.c -index 21d8b8d..18bcda7 100644 ---- a/template.c -+++ b/template.c -@@ -163,6 +163,7 @@ tplToString(struct template *__restrict__ const pTpl, - unsigned short bMustBeFreed = 0; - uchar *pVal; - rs_size_t iLenVal = 0; -+ int need_comma = 0; - - if(pTpl->pStrgen != NULL) { - CHKiRet(pTpl->pStrgen(pMsg, iparam)); -@@ -230,15 +231,24 @@ tplToString(struct template *__restrict__ const pTpl, - if(iBuf + iLenVal + extra_space >= iparam->lenBuf) /* we reserve one char for the final \0! */ - CHKiRet(ExtendBuf(iparam, iBuf + iLenVal + 1)); - -+ if(need_comma) { -+ memcpy(iparam->param + iBuf, ", ", 2); -+ iBuf += 2; -+ } - memcpy(iparam->param + iBuf, pVal, iLenVal); - iBuf += iLenVal; - if(pTpl->optFormatEscape == JSONF) { -- memcpy(iparam->param + iBuf, -- (pTpe->pNext == NULL) ? "}\n" : ", ", 2); -- iBuf += 2; -+ need_comma = 1; - } - } - -+ if((pTpl->optFormatEscape == JSONF) && (pTpe->pNext == NULL)) { -+ /* space was reserved while processing field above -+ (via extra_space in ExtendBuf() new size formula. */ -+ memcpy(iparam->param + iBuf, "}\n", 2); -+ iBuf += 2; -+ } -+ - if(bMustBeFreed) { - free(pVal); - bMustBeFreed = 0; --- +From 246b8d8553b6880146d6c489a28cf4bacea8a199 Mon Sep 17 00:00:00 2001 +From: Rainer Gerhards +Date: Fri, 30 Dec 2022 17:13:17 +0100 +Subject: [PATCH] core bugfix: template system may generate invalid json + +When +- a list template +- is created with option.jsonf="on" +- and the last list element is a property with onEmpty="skip" +- and that property is actually empty +invalid JSON is generated. + +The JSON string in this case ends with ", " instead of "}\n". This +patch fixes the issue. + +closes https://github.com/rsyslog/rsyslog/issues/5050 +--- + +Conflict:NA +Reference:https://github.com/rsyslog/rsyslog/commit/246b8d8553b6880146d6c489a28cf4bacea8a199 +--- + template.c | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +diff --git a/template.c b/template.c +index 21d8b8d..18bcda7 100644 +--- a/template.c ++++ b/template.c +@@ -163,6 +163,7 @@ tplToString(struct template *__restrict__ const pTpl, + unsigned short bMustBeFreed = 0; + uchar *pVal; + rs_size_t iLenVal = 0; ++ int need_comma = 0; + + if(pTpl->pStrgen != NULL) { + CHKiRet(pTpl->pStrgen(pMsg, iparam)); +@@ -230,15 +231,24 @@ tplToString(struct template *__restrict__ const pTpl, + if(iBuf + iLenVal + extra_space >= iparam->lenBuf) /* we reserve one char for the final \0! */ + CHKiRet(ExtendBuf(iparam, iBuf + iLenVal + 1)); + ++ if(need_comma) { ++ memcpy(iparam->param + iBuf, ", ", 2); ++ iBuf += 2; ++ } + memcpy(iparam->param + iBuf, pVal, iLenVal); + iBuf += iLenVal; + if(pTpl->optFormatEscape == JSONF) { +- memcpy(iparam->param + iBuf, +- (pTpe->pNext == NULL) ? "}\n" : ", ", 2); +- iBuf += 2; ++ need_comma = 1; + } + } + ++ if((pTpl->optFormatEscape == JSONF) && (pTpe->pNext == NULL)) { ++ /* space was reserved while processing field above ++ (via extra_space in ExtendBuf() new size formula. */ ++ memcpy(iparam->param + iBuf, "}\n", 2); ++ iBuf += 2; ++ } ++ + if(bMustBeFreed) { + free(pVal); + bMustBeFreed = 0; +-- 2.27.0 \ No newline at end of file diff --git a/backport-core-bugfix-using-uuid-msg-prop-can-deadloc.patch b/backport-core-bugfix-using-uuid-msg-prop-can-deadloc.patch index 33136d1..6fe9811 100644 --- a/backport-core-bugfix-using-uuid-msg-prop-can-deadloc.patch +++ b/backport-core-bugfix-using-uuid-msg-prop-can-deadloc.patch @@ -1,84 +1,84 @@ -From deefc958c388995fac99c581284fb86eb9653ece Mon Sep 17 00:00:00 2001 -From: Rainer Gerhards -Date: Thu, 23 Mar 2023 10:58:32 +0100 -Subject: [PATCH] [backport] core/bugfix: using $uuid msg prop can deadlock - rsyslog on shutdown - -This problem can occur if a large number of threads is used and rsyslog -cannot shut down all queues etc within the regular time interval. In this -case, it cancels some threads. That can leave the mutex guarding libuuid -calls locked and thus prevents other, not yet cancelled threads from -progressing. Assuming pthread_mutex_lock() is not a cancellation point, -this will case these other threads to hang forever and thus create a -deadlock situation. - -closes https://github.com/rsyslog/rsyslog/issues/5104 - ---- - -Conflict:NA -Type:bugfix -Reference:https://github.com/rsyslog/rsyslog/commit/82687e14fbf3d854e8cc954efb9fb0efa69a28d2 - ---- ---- - runtime/msg.c | 19 ++++++++++++------- - 1 file changed, 12 insertions(+), 7 deletions(-) - -diff --git a/runtime/msg.c b/runtime/msg.c -index 73b7cec80..a3ddb8684 100644 ---- a/runtime/msg.c -+++ b/runtime/msg.c -@@ -7,7 +7,7 @@ - * of the "old" message code without any modifications. However, it - * helps to have things at the right place one we go to the meat of it. - * -- * Copyright 2007-2022 Rainer Gerhards and Adiscon GmbH. -+ * Copyright 2007-2023 Rainer Gerhards and Adiscon GmbH. - * - * This file is part of the rsyslog runtime library. - * -@@ -1618,13 +1618,22 @@ msgSetPRI(smsg_t *const __restrict__ pMsg, syslog_pri_t pri) - /* note: libuuid seems not to be thread-safe, so we need - * to get some safeguards in place. - */ -+static pthread_mutex_t mutUUID = PTHREAD_MUTEX_INITIALIZER; -+ -+static void call_uuid_generate(uuid_t uuid) -+{ -+ pthread_mutex_lock(&mutUUID); -+ pthread_cleanup_push(mutexCancelCleanup, &mutUUID); -+ uuid_generate(uuid); -+ pthread_cleanup_pop(1); -+} -+ - static void msgSetUUID(smsg_t * const pM) - { - size_t lenRes = sizeof(uuid_t) * 2 + 1; - char hex_char [] = "0123456789ABCDEF"; - unsigned int byte_nbr; - uuid_t uuid; -- static pthread_mutex_t mutUUID = PTHREAD_MUTEX_INITIALIZER; - - dbgprintf("[MsgSetUUID] START, lenRes %llu\n", (long long unsigned) lenRes); - assert(pM != NULL); -@@ -1632,9 +1641,7 @@ static void msgSetUUID(smsg_t * const pM) - if((pM->pszUUID = (uchar*) malloc(lenRes)) == NULL) { - pM->pszUUID = (uchar *)""; - } else { -- pthread_mutex_lock(&mutUUID); -- uuid_generate(uuid); -- pthread_mutex_unlock(&mutUUID); -+ call_uuid_generate(uuid); - for (byte_nbr = 0; byte_nbr < sizeof (uuid_t); byte_nbr++) { - pM->pszUUID[byte_nbr * 2 + 0] = hex_char[uuid [byte_nbr] >> 4]; - pM->pszUUID[byte_nbr * 2 + 1] = hex_char[uuid [byte_nbr] & 15]; -@@ -5352,5 +5359,3 @@ BEGINObjClassInit(msg, 1, OBJ_IS_CORE_MODULE) - INIT_ATOMIC_HELPER_MUT(mutTrimCtr); - # endif - ENDObjClassInit(msg) --/* vim:set ai: -- */ --- -2.12.3 - +From deefc958c388995fac99c581284fb86eb9653ece Mon Sep 17 00:00:00 2001 +From: Rainer Gerhards +Date: Thu, 23 Mar 2023 10:58:32 +0100 +Subject: [PATCH] [backport] core/bugfix: using $uuid msg prop can deadlock + rsyslog on shutdown + +This problem can occur if a large number of threads is used and rsyslog +cannot shut down all queues etc within the regular time interval. In this +case, it cancels some threads. That can leave the mutex guarding libuuid +calls locked and thus prevents other, not yet cancelled threads from +progressing. Assuming pthread_mutex_lock() is not a cancellation point, +this will case these other threads to hang forever and thus create a +deadlock situation. + +closes https://github.com/rsyslog/rsyslog/issues/5104 + +--- + +Conflict:NA +Type:bugfix +Reference:https://github.com/rsyslog/rsyslog/commit/82687e14fbf3d854e8cc954efb9fb0efa69a28d2 + +--- +--- + runtime/msg.c | 19 ++++++++++++------- + 1 file changed, 12 insertions(+), 7 deletions(-) + +diff --git a/runtime/msg.c b/runtime/msg.c +index 73b7cec80..a3ddb8684 100644 +--- a/runtime/msg.c ++++ b/runtime/msg.c +@@ -7,7 +7,7 @@ + * of the "old" message code without any modifications. However, it + * helps to have things at the right place one we go to the meat of it. + * +- * Copyright 2007-2022 Rainer Gerhards and Adiscon GmbH. ++ * Copyright 2007-2023 Rainer Gerhards and Adiscon GmbH. + * + * This file is part of the rsyslog runtime library. + * +@@ -1618,13 +1618,22 @@ msgSetPRI(smsg_t *const __restrict__ pMsg, syslog_pri_t pri) + /* note: libuuid seems not to be thread-safe, so we need + * to get some safeguards in place. + */ ++static pthread_mutex_t mutUUID = PTHREAD_MUTEX_INITIALIZER; ++ ++static void call_uuid_generate(uuid_t uuid) ++{ ++ pthread_mutex_lock(&mutUUID); ++ pthread_cleanup_push(mutexCancelCleanup, &mutUUID); ++ uuid_generate(uuid); ++ pthread_cleanup_pop(1); ++} ++ + static void msgSetUUID(smsg_t * const pM) + { + size_t lenRes = sizeof(uuid_t) * 2 + 1; + char hex_char [] = "0123456789ABCDEF"; + unsigned int byte_nbr; + uuid_t uuid; +- static pthread_mutex_t mutUUID = PTHREAD_MUTEX_INITIALIZER; + + dbgprintf("[MsgSetUUID] START, lenRes %llu\n", (long long unsigned) lenRes); + assert(pM != NULL); +@@ -1632,9 +1641,7 @@ static void msgSetUUID(smsg_t * const pM) + if((pM->pszUUID = (uchar*) malloc(lenRes)) == NULL) { + pM->pszUUID = (uchar *)""; + } else { +- pthread_mutex_lock(&mutUUID); +- uuid_generate(uuid); +- pthread_mutex_unlock(&mutUUID); ++ call_uuid_generate(uuid); + for (byte_nbr = 0; byte_nbr < sizeof (uuid_t); byte_nbr++) { + pM->pszUUID[byte_nbr * 2 + 0] = hex_char[uuid [byte_nbr] >> 4]; + pM->pszUUID[byte_nbr * 2 + 1] = hex_char[uuid [byte_nbr] & 15]; +@@ -5352,5 +5359,3 @@ BEGINObjClassInit(msg, 1, OBJ_IS_CORE_MODULE) + INIT_ATOMIC_HELPER_MUT(mutTrimCtr); + # endif + ENDObjClassInit(msg) +-/* vim:set ai: +- */ +-- +2.12.3 + diff --git a/backport-imjournal-add-second-fallback-to-_COMM.patch b/backport-imjournal-add-second-fallback-to-_COMM.patch index eba679c..cfed44c 100644 --- a/backport-imjournal-add-second-fallback-to-_COMM.patch +++ b/backport-imjournal-add-second-fallback-to-_COMM.patch @@ -1,38 +1,38 @@ -From 45900dd550e0aca724a4ec66c2833de3d27565e1 Mon Sep 17 00:00:00 2001 -From: alakatos -Date: Mon, 31 Oct 2022 14:40:12 +0100 -Subject: [PATCH] [backport] imjournal: add second fallback to _COMM - -If SYSLOG_IDENTIFIER is not present in the journal message, -then lookup the _COMM field, which stands for the name -of the process the journal entry originates from. This is -needed in order to be in compliance with the journalctl -output. - ---- - -Conflict:NA -Type:bugfix -Reference:https://github.com/rsyslog/rsyslog/commit/fb5ae30e6ac4dc584dd9c5463e27e7fc5e9060a4 - ---- ---- - plugins/imjournal/imjournal.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c -index 6fb3b7a07..4d9e59966 100644 ---- a/plugins/imjournal/imjournal.c -+++ b/plugins/imjournal/imjournal.c -@@ -453,6 +453,8 @@ readjournal(void) - /* Get message identifier, client pid and add ':' */ - if (journalGetData("SYSLOG_IDENTIFIER", &get, &length) >= 0) { - CHKiRet(sanitizeValue(((const char *)get) + 18, length - 18, &sys_iden)); -+ } else if (journalGetData("_COMM", &get, &length) >= 0) { -+ CHKiRet(sanitizeValue(((const char *)get) + 6, length - 6, &sys_iden)); - } else { - CHKmalloc(sys_iden = strdup("journal")); - } --- -2.12.3 - +From 45900dd550e0aca724a4ec66c2833de3d27565e1 Mon Sep 17 00:00:00 2001 +From: alakatos +Date: Mon, 31 Oct 2022 14:40:12 +0100 +Subject: [PATCH] [backport] imjournal: add second fallback to _COMM + +If SYSLOG_IDENTIFIER is not present in the journal message, +then lookup the _COMM field, which stands for the name +of the process the journal entry originates from. This is +needed in order to be in compliance with the journalctl +output. + +--- + +Conflict:NA +Type:bugfix +Reference:https://github.com/rsyslog/rsyslog/commit/fb5ae30e6ac4dc584dd9c5463e27e7fc5e9060a4 + +--- +--- + plugins/imjournal/imjournal.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c +index 6fb3b7a07..4d9e59966 100644 +--- a/plugins/imjournal/imjournal.c ++++ b/plugins/imjournal/imjournal.c +@@ -453,6 +453,8 @@ readjournal(void) + /* Get message identifier, client pid and add ':' */ + if (journalGetData("SYSLOG_IDENTIFIER", &get, &length) >= 0) { + CHKiRet(sanitizeValue(((const char *)get) + 18, length - 18, &sys_iden)); ++ } else if (journalGetData("_COMM", &get, &length) >= 0) { ++ CHKiRet(sanitizeValue(((const char *)get) + 6, length - 6, &sys_iden)); + } else { + CHKmalloc(sys_iden = strdup("journal")); + } +-- +2.12.3 + diff --git a/backport-omprog-bugfix-invalid-status-handling-at-called-prog.patch b/backport-omprog-bugfix-invalid-status-handling-at-called-prog.patch index cf40b4d..ed00e60 100644 --- a/backport-omprog-bugfix-invalid-status-handling-at-called-prog.patch +++ b/backport-omprog-bugfix-invalid-status-handling-at-called-prog.patch @@ -1,47 +1,47 @@ -From 1128d320750fb6cfe57b8ad53ef1d5ddf80c81cf Mon Sep 17 00:00:00 2001 -From: Rainer Gerhards -Date: Sun, 4 Dec 2022 16:05:22 +0100 -Subject: [PATCH] omprog bugfix: invalid status handling at called program - -There is a bug when external program *startup* does not return "OK". This -can also lead to a misadressing with potentially a segfault (very unlikely). -Note that no problem exists once the initializiation phase of the external -program is finished and regular message transfer runs. - -The problem basically is that for a startup failure, the control data for -that external program instance is freed on error. Unfortunately, that state -data is needed later on to detect a suspended instance. We now keep the control -data even on init failure (as we then need to do normal control options). - -closes https://github.com/rsyslog/rsyslog/issues/4967 ---- -Conflict:NA -Reference:https://github.com/rsyslog/rsyslog/commit/1128d320750fb6cfe57b8ad53ef1d5ddf80c81cf ---- - plugins/omprog/omprog.c | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) - -diff --git a/plugins/omprog/omprog.c b/plugins/omprog/omprog.c -index 4f46f92..dd83e93 100644 ---- a/plugins/omprog/omprog.c -+++ b/plugins/omprog/omprog.c -@@ -379,6 +379,7 @@ cleanupChild(instanceData *pData, childProcessCtx_t *pChildCtx) - static void - terminateChild(instanceData *pData, childProcessCtx_t *pChildCtx) - { -+ DBGPRINTF("terminateChild called\n"); - assert(pChildCtx->bIsRunning); - - if (pData->bSignalOnClose) { -@@ -927,9 +928,6 @@ CODESTARTcreateWrkrInstance - } - - finalize_it: -- if(iRet != RS_RET_OK && !pWrkrData->pData->bForceSingleInst) { -- free(pWrkrData->pChildCtx); -- } - ENDcreateWrkrInstance - - --- +From 1128d320750fb6cfe57b8ad53ef1d5ddf80c81cf Mon Sep 17 00:00:00 2001 +From: Rainer Gerhards +Date: Sun, 4 Dec 2022 16:05:22 +0100 +Subject: [PATCH] omprog bugfix: invalid status handling at called program + +There is a bug when external program *startup* does not return "OK". This +can also lead to a misadressing with potentially a segfault (very unlikely). +Note that no problem exists once the initializiation phase of the external +program is finished and regular message transfer runs. + +The problem basically is that for a startup failure, the control data for +that external program instance is freed on error. Unfortunately, that state +data is needed later on to detect a suspended instance. We now keep the control +data even on init failure (as we then need to do normal control options). + +closes https://github.com/rsyslog/rsyslog/issues/4967 +--- +Conflict:NA +Reference:https://github.com/rsyslog/rsyslog/commit/1128d320750fb6cfe57b8ad53ef1d5ddf80c81cf +--- + plugins/omprog/omprog.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/plugins/omprog/omprog.c b/plugins/omprog/omprog.c +index 4f46f92..dd83e93 100644 +--- a/plugins/omprog/omprog.c ++++ b/plugins/omprog/omprog.c +@@ -379,6 +379,7 @@ cleanupChild(instanceData *pData, childProcessCtx_t *pChildCtx) + static void + terminateChild(instanceData *pData, childProcessCtx_t *pChildCtx) + { ++ DBGPRINTF("terminateChild called\n"); + assert(pChildCtx->bIsRunning); + + if (pData->bSignalOnClose) { +@@ -927,9 +928,6 @@ CODESTARTcreateWrkrInstance + } + + finalize_it: +- if(iRet != RS_RET_OK && !pWrkrData->pData->bForceSingleInst) { +- free(pWrkrData->pChildCtx); +- } + ENDcreateWrkrInstance + + +-- 2.27.0 \ No newline at end of file diff --git a/backport-outchannel-eleminate-type-cast-for-compatibility-rea.patch b/backport-outchannel-eleminate-type-cast-for-compatibility-rea.patch new file mode 100644 index 0000000..c6e332f --- /dev/null +++ b/backport-outchannel-eleminate-type-cast-for-compatibility-rea.patch @@ -0,0 +1,74 @@ +From d8c9771ad5d4a9ef952968a3aeadcecc2e1752a6 Mon Sep 17 00:00:00 2001 +From: Dominik Andreas Schorpp +Date: Mon, 2 Jan 2023 15:27:39 +0100 +Subject: [PATCH] outchannel: eleminate type cast for compatibility reasons + +According to the manpage the input for isspace must be of type unsigend char. +Remove all unnecessary type cast to achieve this. + +Reference:https://github.com/rsyslog/rsyslog/pull/5056 +Conflict:NA + +Signed-off-by: Dominik Andreas Schorpp +--- + outchannel.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/outchannel.c b/outchannel.c +index 2f456b5..2362810 100644 +--- a/outchannel.c ++++ b/outchannel.c +@@ -67,19 +67,19 @@ struct outchannel* ochConstruct(void) + /* skips the next comma and any whitespace + * in front and after it. + */ +-static void skip_Comma(char **pp) ++static void skip_Comma(uchar **pp) + { +- register char *p; ++ register uchar *p; + + assert(pp != NULL); + assert(*pp != NULL); + + p = *pp; +- while(isspace((int)*p)) ++ while(isspace(*p)) + ++p; + if(*p == ',') + ++p; +- while(isspace((int)*p)) ++ while(isspace(*p)) + ++p; + *pp = p; + } +@@ -98,7 +98,7 @@ static rsRetVal get_Field(uchar **pp, uchar **pField) + assert(*pp != NULL); + assert(pField != NULL); + +- skip_Comma((char**)pp); ++ skip_Comma(pp); + p = *pp; + + CHKiRet(cstrConstruct(&pStrB)); +@@ -135,7 +135,7 @@ static int get_off_t(uchar **pp, off_t *pOff_t) + assert(*pp != NULL); + assert(pOff_t != NULL); + +- skip_Comma((char**)pp); ++ skip_Comma(pp); + p = *pp; + + val = 0; +@@ -166,7 +166,7 @@ static rsRetVal get_restOfLine(uchar **pp, uchar **pBuf) + assert(*pp != NULL); + assert(pBuf != NULL); + +- skip_Comma((char**)pp); ++ skip_Comma(pp); + p = *pp; + + CHKiRet(cstrConstruct(&pStrB)); +-- +2.23.0 + diff --git a/rsyslog.spec b/rsyslog.spec index 273aa0f..803a259 100644 --- a/rsyslog.spec +++ b/rsyslog.spec @@ -7,7 +7,7 @@ Name: rsyslog Version: 8.2210.0 -Release: 3 +Release: 4 Summary: The rocket-fast system for log processing License: (GPLv3+ and ASL 2.0) URL: http://www.rsyslog.com/ @@ -39,6 +39,7 @@ Patch6004: backport-imjournal-add-second-fallback-to-_COMM.patch Patch6005: backport-bugfix-prevent-pot.-segfault-when-switchung.patch Patch6006: backport-core-bugfix-using-uuid-msg-prop-can-deadloc.patch Patch6007: backport-GNUTls-Driver-Fix-memory-leaks-in-gtlsInitC.patch +Patch6008: backport-outchannel-eleminate-type-cast-for-compatibility-rea.patch BuildRequires: gcc autoconf automake bison dos2unix flex pkgconfig python3-docutils libtool BuildRequires: libgcrypt-devel libuuid-devel zlib-devel krb5-devel libnet-devel gnutls-devel @@ -513,6 +514,12 @@ done %{_mandir}/man1/rscryutil.1.gz %changelog +* Tue Sep 19 2023 zhangqiumiao - 8.2210.0-4 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC: outchannel: eleminate type cast for compatibility reasons + * Sun Jun 25 2023 linzhuorong - 8.2210.0-3 - Type:NA - ID:NA -- Gitee