diff --git a/backport-Fix-memory-leak-when-SetString.patch b/backport-Fix-memory-leak-when-SetString.patch new file mode 100644 index 0000000000000000000000000000000000000000..48aadd4cd0a10c98666cb3b337af39006b271145 --- /dev/null +++ b/backport-Fix-memory-leak-when-SetString.patch @@ -0,0 +1,32 @@ +From b3ba1d7280bab1b623e1b2aaf390bbae8aa8c484 Mon Sep 17 00:00:00 2001 +From: seuzw930 <76191785+seuzw930@users.noreply.github.com> +Date: Sun, 14 Aug 2022 16:52:53 +0800 +Subject: [PATCH] Fix memory leak when SetString + +During SetString reassign to pThis->szVal.psz, pThis->szVal.psz might not null. It resulted in memory leak and this patch fixes this behaviour. + +The problem is mentioned here: +https://github.com/rsyslog/rsyslog/issues/4961From f65b8860358b7aaca76d3abe086ac2bf80e2079b Mon Sep 17 00:00:00 2001 + +Conflict:NA +Reference:https://github.com/rsyslog/rsyslog/commit/b3ba1d7280bab1b623e1b2aaf390bbae8aa8c484 +--- + runtime/prop.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/runtime/prop.c b/runtime/prop.c +index 866b691..c4de5d7 100644 +--- a/runtime/prop.c ++++ b/runtime/prop.c +@@ -84,6 +84,9 @@ static rsRetVal SetString(prop_t *pThis, const uchar *psz, const int len) + if(len < CONF_PROP_BUFSIZE) { + memcpy(pThis->szVal.sz, psz, len + 1); + } else { ++ if(pThis->szVal.psz != NULL) { ++ free(pThis->szVal.psz); ++ } + CHKmalloc(pThis->szVal.psz = malloc(len + 1)); + memcpy(pThis->szVal.psz, psz, len + 1); + } +-- +2.27.0 diff --git a/backport-Simplified-and-fixed-IPv4-digit-detection.patch b/backport-Simplified-and-fixed-IPv4-digit-detection.patch new file mode 100644 index 0000000000000000000000000000000000000000..50c88f13f9e704931219d9e851a11ef7de508224 --- /dev/null +++ b/backport-Simplified-and-fixed-IPv4-digit-detection.patch @@ -0,0 +1,218 @@ +From a335ec06f0897a71356afee3362f67e68b91a3de Mon Sep 17 00:00:00 2001 +From: Andre lorbach +Date: Thu, 28 Jul 2022 16:17:41 +0200 +Subject: [PATCH] mmanon: Simplified and fixed IPv4 digit detection. + +- Fixed an issue with numbers above int64 in syntax_ipv4. + Numbers that were up to 256 above the max of an int64 + could incorrectly be detected as valid ipv4 digit. +- Simplified the IPv4 digit detection function and renamed + to isPosByte. +- added testcasse for malformed IPvc4 addresses + +closes: https://github.com/rsyslog/rsyslog/issues/4940 + +Conflict:NA +Reference:https://github.com/rsyslog/rsyslog/commit/a335ec06f0897a71356afee3362f67e68b91a3de +--- + plugins/mmanon/mmanon.c | 55 ++++++++++++++------------ + tests/Makefile.am | 2 + + tests/mmanon_recognize_ipv4.sh | 4 ++ + tests/mmanon_simple_mallformed_ipv4.sh | 37 +++++++++++++++++ + 4 files changed, 73 insertions(+), 25 deletions(-) + create mode 100755 tests/mmanon_simple_mallformed_ipv4.sh + +diff --git a/plugins/mmanon/mmanon.c b/plugins/mmanon/mmanon.c +index a2ebd7b..4f83076 100644 +--- a/plugins/mmanon/mmanon.c ++++ b/plugins/mmanon/mmanon.c +@@ -22,6 +22,7 @@ + #include "config.h" + #include "rsyslog.h" + #include ++#include + #include + #include + #include +@@ -388,72 +389,76 @@ getHexVal(char c) + } + + +-/* returns -1 if no integer found, else integer */ +-static int64_t +-getPosInt(const uchar *const __restrict__ buf, ++/* returns 1 if valid IPv4 digit, 0 if not */ ++static int ++isPosByte(const uchar *const __restrict__ buf, + const size_t buflen, + size_t *const __restrict__ nprocessed) + { +- int64_t val = 0; ++ int val = 0; /* Default means no byte found */ + size_t i; +- for(i = 0 ; i < buflen ; i++) { +- if('0' <= buf[i] && buf[i] <= '9') +- val = val*10 + buf[i]-'0'; +- else ++ for(i = 0 ; i < buflen; i++) { ++ if('0' <= buf[i] && buf[i] <= '9') { ++ /* Maximum 3 digits for single IPv4 Number, we only copy up to 4 numbers ++ * but process forward to non digits */ ++ if (i < 4) { ++ val = val*10 + buf[i]-'0'; ++ } ++ } else + break; + } + *nprocessed = i; +- if(i == 0) +- val = -1; +- return val; ++ /* Return 1 if more than 1 and less the 4 digits and between 0 and 255 */ ++ if( i > 0 && ++ i < 4 && ++ (val >= 0 && val <= 255)) { ++ return 1; ++ } else { ++ return 0; ++ } + } + + /* 1 - is IPv4, 0 not */ +- + static int + syntax_ipv4(const uchar *const __restrict__ buf, + const size_t buflen, + size_t *const __restrict__ nprocessed) + { +- int64_t val; +- size_t nproc; ++ size_t nproc = 0; + size_t i; + int r = 0; +- +- val = getPosInt(buf, buflen, &i); +- if(val < 0 || val > 255) ++ if(isPosByte(buf, buflen, &i) == 0) { + goto done; +- ++ } + if(i >= buflen || buf[i] != '.') { + goto done; + } + i++; +- val = getPosInt(buf+i, buflen-i, &nproc); +- if(val < 0 || val > 255) ++ if(isdigit(buf[i]) == 0 || isPosByte(buf+i, buflen-i, &nproc) == 0) { + goto done; ++ } + i += nproc; + + if(i >= buflen || buf[i] != '.') { + goto done; + } + i++; +- val = getPosInt(buf+i, buflen-i, &nproc); +- if(val < 0 || val > 255) ++ if(isdigit(buf[i]) == 0 || isPosByte(buf+i, buflen-i, &nproc) == 0) { + goto done; ++ } + i += nproc; + + if(i >= buflen || buf[i] != '.') { + goto done; + } + i++; +- val = getPosInt(buf+i, buflen-i, &nproc); +- if(val < 0 || val > 255) ++ if(isdigit(buf[i]) == 0 || isPosByte(buf+i, buflen-i, &nproc) == 0) { + goto done; ++ } + i += nproc; + + *nprocessed = i; + r = 1; +- + done: + return r; + } +diff --git a/tests/Makefile.am b/tests/Makefile.am +index d3b040b..5e4f4fe 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -587,6 +587,7 @@ TESTS += \ + mmanon_simple_12_ipv4.sh \ + mmanon_simple_33_ipv4.sh \ + mmanon_simple_8_ipv4.sh \ ++ mmanon_simple_mallformed_ipv4.sh \ + mmanon_random_128_ipv6.sh \ + mmanon_zero_128_ipv6.sh \ + mmanon_zero_96_ipv6.sh \ +@@ -1872,6 +1873,7 @@ EXTRA_DIST= \ + mmanon_simple_12_ipv4.sh \ + mmanon_simple_33_ipv4.sh \ + mmanon_simple_8_ipv4.sh \ ++ mmanon_simple_mallformed_ipv4.sh \ + mmanon_random_128_ipv6.sh \ + mmanon_zero_128_ipv6.sh \ + mmanon_zero_96_ipv6.sh \ +diff --git a/tests/mmanon_recognize_ipv4.sh b/tests/mmanon_recognize_ipv4.sh +index fb7eb9f..cd9dcca 100755 +--- a/tests/mmanon_recognize_ipv4.sh ++++ b/tests/mmanon_recognize_ipv4.sh +@@ -2,6 +2,10 @@ + # add 2016-11-22 by Jan Gerhards, released under ASL 2.0 + + . ${srcdir:=.}/diag.sh init ++ ++#export RSYSLOG_DEBUG="debug nostdout noprintmutexaction" ++#export RSYSLOG_DEBUGLOG="$RSYSLOG_DYNNAME.debuglog" ++ + generate_conf + add_conf ' + template(name="outfmt" type="string" string="%msg%\n") +diff --git a/tests/mmanon_simple_mallformed_ipv4.sh b/tests/mmanon_simple_mallformed_ipv4.sh +new file mode 100755 +index 0000000..7ef8899 +--- /dev/null ++++ b/tests/mmanon_simple_mallformed_ipv4.sh +@@ -0,0 +1,37 @@ ++#!/bin/bash ++# add 2022-07-28 by Andre Lorbach, released under ASL 2.0 ++ ++. ${srcdir:=.}/diag.sh init ++#export USE_VALGRIND="YES" # this test only makes sense with valgrind enabled ++#export RS_TEST_VALGRIND_EXTRA_OPTS="--keep-debuginfo=yes" ++ ++#export RSYSLOG_DEBUG="debug nostdout noprintmutexaction" ++#export RSYSLOG_DEBUGLOG="$RSYSLOG_DYNNAME.debuglog" ++ ++generate_conf ++add_conf ' ++template(name="outfmt" type="string" string="%msg%\n") ++ ++module(load="../plugins/mmanon/.libs/mmanon") ++module(load="../plugins/imtcp/.libs/imtcp") ++input(type="imtcp" port="0" listenPortFileName="'$RSYSLOG_DYNNAME'.tcpflood_port" ruleset="testing") ++ ++ruleset(name="testing") { ++ action(type="mmanon" ipv4.bits="32" ipv4.mode="simple") ++ action(type="omfile" file=`echo $RSYSLOG_OUT_LOG` template="outfmt") ++}' ++ ++startup ++tcpflood -m1 -M "\"<129>Mar 10 01:00:00 172.20.245.8 tag: 165874883373.1.15599155266856607338.91@whatever ++<129>Mar 10 01:00:00 172.20.245.8 tag: 1.165874883373.15599155266856607338.91@whatever ++<129>Mar 10 01:00:00 172.20.245.8 tag: 15599155266856607338.165874883373.1.91@whatever ++<129>Mar 10 01:00:00 172.20.245.8 tag: 91.165874883373.1.15599155266856607338.@whatever\"" ++ ++shutdown_when_empty ++wait_shutdown ++export EXPECTED=' 165874883373.1.15599155266856607338.91@whatever ++ 1.165874883373.15599155266856607338.91@whatever ++ 15599155266856607338.165874883373.1.91@whatever ++ 91.165874883373.1.15599155266856607338.@whatever' ++cmp_exact ++exit_test +-- +2.27.0 diff --git a/backport-core-bugfix-correct-local-host-name-after-config-processing.patch b/backport-core-bugfix-correct-local-host-name-after-config-processing.patch new file mode 100644 index 0000000000000000000000000000000000000000..ee809fe5574ab847b2f6ced1e09fc0b5044af012 --- /dev/null +++ b/backport-core-bugfix-correct-local-host-name-after-config-processing.patch @@ -0,0 +1,258 @@ +From ba00a9f25293f72137c9a85010276cca014ae7f0 Mon Sep 17 00:00:00 2001 +From: Rainer Gerhards +Date: Wed, 31 Aug 2022 17:37:07 +0200 +Subject: [PATCH] core bugfix: correct local host name after config processing + +rsyslog.conf may affect the host's local name. These changes were +so far only activated after the first HUP. This patch now ensures +that the configured local host name is applied correctly throughout +all processing, including early startup. + +This patch causes a slight change of behaviour. However, the behaviour +was inconsitent before. Now it is consistent and according to the config. + +Please note: this patch also exposes a global entry point via "regular" +dynamic loading as this makes things much easier to do. This is in-line +with ongoing simplification effort. + +Finally, we also remove a CI test that we do no longer need because +the problem covered is now addressed differently and the original issue +can no longer occur. + +closes https://github.com/rsyslog/rsyslog/issues/4975 + +Conflict:NA +Reference:https://github.com/rsyslog/rsyslog/commit/ba00a9f25293f72137c9a85010276cca014ae7f0 +--- + runtime/glbl.c | 16 +++++++++++--- + runtime/glbl.h | 3 ++- + runtime/rsyslog.h | 2 +- + tests/Makefile.am | 6 ------ + tests/hostname-getaddrinfo-fail.sh | 34 ------------------------------ + tools/iminternal.c | 7 +++++- + tools/rsyslogd.c | 10 ++------- + 7 files changed, 24 insertions(+), 54 deletions(-) + delete mode 100755 tests/hostname-getaddrinfo-fail.sh + +diff --git a/runtime/glbl.c b/runtime/glbl.c +index 52a598f..4feefc4 100644 +--- a/runtime/glbl.c ++++ b/runtime/glbl.c +@@ -619,8 +619,8 @@ SetLocalHostName(uchar *const newname) + + /* return our local hostname. if it is not set, "[localhost]" is returned + */ +-static uchar* +-GetLocalHostName(void) ++uchar* ++glblGetLocalHostName(void) + { + uchar *pszRet; + +@@ -910,6 +910,8 @@ CODESTARTobjQueryInterface(glbl) + pIf->GetOption_DisallowWarning = getOption_DisallowWarning; + pIf->SetParseHOSTNAMEandTAG = setParseHOSTNAMEandTAG; + pIf->GetParseHOSTNAMEandTAG = getParseHOSTNAMEandTAG; ++ pIf->GetLocalHostName = glblGetLocalHostName; ++ pIf->SetLocalHostName = SetLocalHostName; + #define SIMP_PROP(name) \ + pIf->Get##name = Get##name; \ + pIf->Set##name = Set##name; +@@ -917,7 +919,6 @@ CODESTARTobjQueryInterface(glbl) + SIMP_PROP(DropMalPTRMsgs); + SIMP_PROP(mainqCnfObj); + SIMP_PROP(LocalFQDNName) +- SIMP_PROP(LocalHostName) + SIMP_PROP(LocalDomain) + SIMP_PROP(StripDomains) + SIMP_PROP(LocalHosts) +@@ -1541,6 +1542,15 @@ glblDoneLoadCnf(void) + stddbg = -1; + } + ++ /* we have now read the config. We need to query the local host name now ++ * as it was set by the config. ++ * ++ * Note: early messages are already emited, and have "[localhost]" as ++ * hostname. These messages are currently in iminternal queue. Once they ++ * are taken from that queue, the hostname will be adapted. ++ */ ++ queryLocalHostname(); ++ + finalize_it: RETiRet; + } + +diff --git a/runtime/glbl.h b/runtime/glbl.h +index 9ccf7b6..4cb5770 100644 +--- a/runtime/glbl.h ++++ b/runtime/glbl.h +@@ -8,7 +8,7 @@ + * Please note that there currently is no glbl.c file as we do not yet + * have any implementations. + * +- * Copyright 2008-2019 Rainer Gerhards and Adiscon GmbH. ++ * Copyright 2008-2022 Rainer Gerhards and Adiscon GmbH. + * + * This file is part of the rsyslog runtime library. + * +@@ -162,5 +162,6 @@ const uchar* glblGetOperatingStateFile(void); + int glblGetOversizeMsgInputMode(void); + int glblReportOversizeMessage(void); + void glblReportChildProcessExit(const uchar *name, pid_t pid, int status); ++uchar *glblGetLocalHostName(void); + + #endif /* #ifndef GLBL_H_INCLUDED */ +diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h +index 6492eea..58f8219 100644 +--- a/runtime/rsyslog.h ++++ b/runtime/rsyslog.h +@@ -757,8 +757,8 @@ rsRetVal rsrtInit(const char **ppErrObj, obj_if_t *pObjIF); + rsRetVal rsrtExit(void); + int rsrtIsInit(void); + void rsrtSetErrLogger(void (*errLogger)(const int, const int, const uchar*)); +- + void dfltErrLogger(const int, const int, const uchar *errMsg); ++rsRetVal queryLocalHostname(void); + + + /* this define below is (later) intended to be used to implement empty +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 5e4f4fe..34b5b38 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -175,7 +175,6 @@ TESTS += \ + timestamp-mysql.sh \ + timestamp-pgsql.sh \ + timestamp-subseconds.sh \ +- hostname-getaddrinfo-fail.sh \ + msleep_usage_output.sh \ + mangle_qi_usage_output.sh \ + minitcpsrv_usage_output.sh \ +@@ -1608,10 +1607,6 @@ TESTS += \ + endif + endif # ENABLE_OMAMQP1 + +-# test samples... +-#empty-hostname.log: hostname-getaddrinfo-fail.log +-#hostname-getaddrinfo-fail.log: empty-hostname.log +- + endif # if ENABLE_TESTBENCH + + TESTS_ENVIRONMENT = RSYSLOG_MODDIR='$(abs_top_builddir)'/runtime/.libs/ +@@ -1648,7 +1643,6 @@ EXTRA_DIST= \ + config_enabled-off.sh \ + empty-app-name.sh \ + empty-hostname.sh \ +- hostname-getaddrinfo-fail.sh \ + hostname-with-slash-pmrfc5424.sh \ + hostname-with-slash-pmrfc3164.sh \ + pmrfc3164-msgFirstSpace.sh \ +diff --git a/tests/hostname-getaddrinfo-fail.sh b/tests/hostname-getaddrinfo-fail.sh +deleted file mode 100755 +index d14a1c3..0000000 +--- a/tests/hostname-getaddrinfo-fail.sh ++++ /dev/null +@@ -1,34 +0,0 @@ +-#!/bin/bash +-# This test check what happens if we cannot doe getaddrinfo early +-# in rsyslog startup (this has caused an error in the past). Even more +-# importantly, it checks that error messages can be issued very early +-# during startup. +-# Note that we use the override of the hostname to ensure we do not +-# accidentally get an acceptable FQDN-type hostname during testing. +-# +-# IMPORTANT: We cannot use the regular plumbing here, as our preload +-# interferes with socket operations (we cannot bind the port for some +-# reason). As we do not necessarily need the full plumbing for this +-# simple test, we emulate what we need. It's a bit ugly, but actually +-# the simplest way forward. +-# +-# This is part of the rsyslog testbench, licensed under ASL 2.0 +-. ${srcdir:=.}/diag.sh init +-skip_platform "AIX" "we cannot preload required dummy lib" +- +-echo 'action(type="omfile" file="'$RSYSLOG_DYNNAME'.out.log")' > ${RSYSLOG_DYNNAME}.conf +-LD_PRELOAD=".libs/liboverride_gethostname_nonfqdn.so:.libs/liboverride_getaddrinfo.so" \ +- ../tools/rsyslogd -C -n -i$RSYSLOG_DYNNAME.pid -M../runtime/.libs:../.libs -f${RSYSLOG_DYNNAME}.conf & +-wait_process_startup $RSYSLOG_DYNNAME +-sleep 1 # wait a bit so that rsyslog can do some processing... +-kill $(cat $RSYSLOG_DYNNAME.pid ) +- +-grep " nonfqdn " < $RSYSLOG_DYNNAME.out.log +-if [ ! $? -eq 0 ]; then +- echo "expected hostname \"nonfqdn\" not found in logs, $RSYSLOG_DYNNAME.out.log is:" +- cat $RSYSLOG_DYNNAME.out.log +- error_exit 1 +-fi; +- +-echo EVERYTHING OK - error messages are just as expected! +-exit_test +diff --git a/tools/iminternal.c b/tools/iminternal.c +index 52e9df8..c4dd548 100644 +--- a/tools/iminternal.c ++++ b/tools/iminternal.c +@@ -6,7 +6,7 @@ + * + * File begun on 2007-08-03 by RGerhards + * +- * Copyright 2007-2017 Rainer Gerhards and Adiscon GmbH. ++ * Copyright 2007-2022 Rainer Gerhards and Adiscon GmbH. + * + * This file is part of rsyslog. + * +@@ -37,6 +37,7 @@ + #include "syslogd.h" + #include "linkedlist.h" + #include "iminternal.h" ++#include "unicode-helper.h" + + static linkedList_t llMsgs; + static pthread_mutex_t mutList = PTHREAD_MUTEX_INITIALIZER; +@@ -137,6 +138,10 @@ rsRetVal iminternalRemoveMsg(smsg_t **ppMsg) + + pthread_mutex_lock(&mutList); + CHKiRet(llGetNextElt(&llMsgs, &llCookie, (void*)&pThis)); ++ if(!strcmp((char*)pThis->pMsg->pszHOSTNAME, "[localhost]")) { ++ /* early (pre-conf) startup message detected, need to set real hostname now */ ++ MsgSetHOSTNAME(pThis->pMsg, glblGetLocalHostName(), ustrlen(glblGetLocalHostName())); ++ } + *ppMsg = pThis->pMsg; + pThis->pMsg = NULL; /* we do no longer own it - important for destructor */ + +diff --git a/tools/rsyslogd.c b/tools/rsyslogd.c +index 8410d44..9dedd2f 100644 +--- a/tools/rsyslogd.c ++++ b/tools/rsyslogd.c +@@ -3,7 +3,7 @@ + * because it was either written from scratch by me (rgerhards) or + * contributors who agreed to ASL 2.0. + * +- * Copyright 2004-2019 Rainer Gerhards and Adiscon ++ * Copyright 2004-2022 Rainer Gerhards and Adiscon + * + * This file is part of rsyslog. + * +@@ -231,7 +231,7 @@ setsid(void) + #endif + + +-static rsRetVal ++rsRetVal + queryLocalHostname(void) + { + uchar *LocalHostName = NULL; +@@ -1384,12 +1384,6 @@ initAll(int argc, char **argv) + 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(); +- + /* we now can emit error messages "the regular way" */ + + if(getenv("TZ") == NULL) { +-- +2.27.0 diff --git a/backport-core-bugfix-local-hostname-invalid-if-no-global-config-object-given.patch b/backport-core-bugfix-local-hostname-invalid-if-no-global-config-object-given.patch new file mode 100644 index 0000000000000000000000000000000000000000..1949f11fba98fa04b4cfadb53b89dd08c2fed7eb --- /dev/null +++ b/backport-core-bugfix-local-hostname-invalid-if-no-global-config-object-given.patch @@ -0,0 +1,45 @@ +From e2beca531157a4c0a27bcdda689bc53373e305b3 Mon Sep 17 00:00:00 2001 +From: Rainer Gerhards +Date: Thu, 20 Oct 2022 18:08:11 +0200 +Subject: [PATCH] core bugfix: local hostname invalid if no global() config + object given + +The local hostname is invalidly set to "[localhost]" on rsyslog startup +if no global() config object is present in rsyslog.conf. Sending a HUP +corrects the hostname. + +This is a regression from ba00a9f25293f + +closes https://github.com/rsyslog/rsyslog/issues/4975, +closes https://github.com/rsyslog/rsyslog/issues/4825From cfe12d3df739adc6e583e3d4dd798f492b0aa17e Mon Sep 17 00:00:00 2001 + +Conflict:NA +Reference:https://github.com/rsyslog/rsyslog/commit/e2beca531157a4c0a27bcdda689bc53373e305b3 +--- + runtime/glbl.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/runtime/glbl.c b/runtime/glbl.c +index ff11419..71c3989 100644 +--- a/runtime/glbl.c ++++ b/runtime/glbl.c +@@ -1567,6 +1567,7 @@ glblDoneLoadCnf(void) + stddbg = -1; + } + ++finalize_it: + /* we have now read the config. We need to query the local host name now + * as it was set by the config. + * +@@ -1575,8 +1576,7 @@ glblDoneLoadCnf(void) + * are taken from that queue, the hostname will be adapted. + */ + queryLocalHostname(); +- +-finalize_it: RETiRet; ++ RETiRet; + } + + +-- +2.27.0 diff --git a/backport-tcpsrv-cleanup-remove-commented-out-code.patch b/backport-tcpsrv-cleanup-remove-commented-out-code.patch new file mode 100644 index 0000000000000000000000000000000000000000..de3ac4ff5cca54e295890056da2a5d03f431d6ed --- /dev/null +++ b/backport-tcpsrv-cleanup-remove-commented-out-code.patch @@ -0,0 +1,39 @@ +From 22bef1c86200e594fd6d5d42fb10647d1303874f Mon Sep 17 00:00:00 2001 +From: Rainer Gerhards +Date: Tue, 23 Aug 2022 14:45:11 +0200 +Subject: [PATCH] tcpsrv: cleanup - remove commented out code + +Conflict:NA +Reference:https://github.com/rsyslog/rsyslog/commit/22bef1c86200e594fd6d5d42fb10647d1303874f +--- + runtime/tcpsrv.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/runtime/tcpsrv.c b/runtime/tcpsrv.c +index 2c91c2e..2feb2cc 100644 +--- a/runtime/tcpsrv.c ++++ b/runtime/tcpsrv.c +@@ -604,7 +604,6 @@ doReceive(tcpsrv_t *pThis, tcps_sess_t **ppSess, nspoll_t *pPoll) + case RS_RET_CLOSED: + if(pThis->bEmitMsgOnClose) { + errno = 0; +- // prop.GetString((*ppSess)->fromHostIP, &pszPeer, &lenPeer); + LogError(0, RS_RET_PEER_CLOSED_CONN, "Netstream session %p closed by remote " + "peer %s.\n", (*ppSess)->pStrm, pszPeer); + } +@@ -620,13 +619,11 @@ doReceive(tcpsrv_t *pThis, tcps_sess_t **ppSess, nspoll_t *pPoll) + /* in this case, something went awfully wrong. + * We are instructed to terminate the session. + */ +- // prop.GetString((*ppSess)->fromHostIP, &pszPeer, &lenPeer); + LogError(oserr, localRet, "Tearing down TCP Session from %s", pszPeer); + CHKiRet(closeSess(pThis, ppSess, pPoll)); + } + break; + default: +- // prop.GetString((*ppSess)->fromHostIP, &pszPeer, &lenPeer); + LogError(oserr, iRet, "netstream session %p from %s will be closed due to error", + (*ppSess)->pStrm, pszPeer); + CHKiRet(closeSess(pThis, ppSess, pPoll)); +-- +2.27.0 diff --git a/print-main-queue-info-to-journal-when-queue-full.patch b/print-main-queue-info-to-journal-when-queue-full.patch index ab50631d084ba596de6d8cc2e9a037f7ddb0793b..4eaaf42a49846ec0b973139a8040f71f0e123e28 100644 --- a/print-main-queue-info-to-journal-when-queue-full.patch +++ b/print-main-queue-info-to-journal-when-queue-full.patch @@ -1,77 +1,85 @@ -From 27ee1b988a465e5f89e8a9234f4a01c34cab4387 Mon Sep 17 00:00:00 2001 -From: wangshouping -Date: Mon, 27 Apr 2020 08:53:18 -0400 -Subject: [PATCH] print main queue info to journal when queue full -Signed-off-by: wangshouping ---- - runtime/queue.c | 27 +++++++++++++++++++++++++++ - 1 files changed, 45 insertions(+), 1 deletion(-) -diff --git a/runtime/queue.c b/runtime/queue.c -index e988e44..9faf5aa 100644 ---- a/runtime/queue.c -+++ b/runtime/queue.c -@@ -47,6 +47,7 @@ - #include - #include - #include -+#include - - #include "rsyslog.h" - #include "queue.h" -@@ -116,6 +117,14 @@ rsRetVal qqueueSetSpoolDir(qqueue_t *pThis, uchar *pszSpoolDir, int lenSpoolDir) - /* some constants for queuePersist () */ - #define QUEUE_CHECKPOINT 1 - #define QUEUE_NO_CHECKPOINT 0 -+#define TIME_OUT 300 -+#define TIMEOUT_ENQUEUE_ZERO 1 -+#define TIMEOUT_ENQUEUE_NONZERO 2 -+ -+struct timespec g_lastTime = { -+ .tv_sec = 0, -+ .tv_nsec = 0, -+}; - - /* tables for interfacing with the v6 config system */ - static struct cnfparamdescr cnfpdescr[] = { -@@ -2985,6 +2992,24 @@ finalize_it: - RETiRet; - } - -+void PrintQueueFullLog(qqueue_t *pThis, int flag) -+{ -+ struct timespec timeNow; -+ -+ clock_gettime(CLOCK_MONOTONIC, &timeNow); -+ if (timeNow.tv_sec - g_lastTime.tv_sec > TIME_OUT) { -+ if (flag == TIMEOUT_ENQUEUE_ZERO) { -+ sd_journal_print(LOG_NOTICE, "doEnqSingleObject: queue FULL - configured for immediate " -+ "discarding QueueSize=%d MaxQueueSize=%d sizeOnDisk=%lld " -+ "sizeOnDiskMax=%lld\n", pThis->iQueueSize, pThis->iMaxQueueSize, -+ pThis->tVars.disk.sizeOnDisk, pThis->sizeOnDiskMax); -+ } else if (flag == TIMEOUT_ENQUEUE_NONZERO) { -+ sd_journal_print(LOG_NOTICE, "doEnqSingleObject: queue FULL, iQueueSize=%d MaxQueueSize=%d - waiting %dms to drain.\n", -+ pThis->iQueueSize, pThis->iMaxQueueSize, pThis->toEnq); -+ } -+ g_lastTime.tv_sec = timeNow.tv_sec; -+ } -+} - - /* enqueue a single data object. - * Note that the queue mutex MUST already be locked when this function is called. -@@ -3082,12 +3107,14 @@ doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, smsg_t *pMsg) - "discarding QueueSize=%d MaxQueueSize=%d sizeOnDisk=%lld " - "sizeOnDiskMax=%lld\n", pThis->iQueueSize, pThis->iMaxQueueSize, - pThis->tVars.disk.sizeOnDisk, pThis->sizeOnDiskMax); -+ PrintQueueFullLog(pThis, TIMEOUT_ENQUEUE_ZERO); - STATSCOUNTER_INC(pThis->ctrFDscrd, pThis->mutCtrFDscrd); - msgDestruct(&pMsg); - ABORT_FINALIZE(RS_RET_QUEUE_FULL); - } else { - DBGOPRINT((obj_t*) pThis, "doEnqSingleObject: queue FULL - waiting %dms to drain.\n", - pThis->toEnq); -+ PrintQueueFullLog(pThis, TIMEOUT_ENQUEUE_NONZERO); - if(glbl.GetGlobalInputTermState()) { - DBGOPRINT((obj_t*) pThis, "doEnqSingleObject: queue FULL, discard due to " - "FORCE_TERM.\n"); --- -2.19.1 \ No newline at end of file +From 27ee1b988a465e5f89e8a9234f4a01c34cab4387 Mon Sep 17 00:00:00 2001 +From: wangshouping +Date: Mon, 27 Apr 2020 08:53:18 -0400 +Subject: [PATCH] print main queue info to journal when queue full +Signed-off-by: wangshouping + +V-2: add macro control for systemd/sd-journal.h +Signed-off-by: pengyi37 + +--- + runtime/queue.c | 31 +++++++++++++++++++++++++++++++ + 1 file changed, 31 insertions(+) + +diff --git a/runtime/queue.c b/runtime/queue.c +index 3083fb9..b3fdd51 100644 +--- a/runtime/queue.c ++++ b/runtime/queue.c +@@ -47,6 +47,9 @@ + #include + #include + #include ++#ifdef HAVE_LIBSYSTEMD ++# include ++#endif + + #include "rsyslog.h" + #include "queue.h" +@@ -116,6 +119,14 @@ rsRetVal qqueueSetSpoolDir(qqueue_t *pThis, uchar *pszSpoolDir, int lenSpoolDir) + /* some constants for queuePersist () */ + #define QUEUE_CHECKPOINT 1 + #define QUEUE_NO_CHECKPOINT 0 ++#define TIME_OUT 300 ++#define TIMEOUT_ENQUEUE_ZERO 1 ++#define TIMEOUT_ENQUEUE_NONZERO 2 ++ ++struct timespec g_lastTime = { ++ .tv_sec = 0, ++ .tv_nsec = 0, ++}; + + /* tables for interfacing with the v6 config system */ + static struct cnfparamdescr cnfpdescr[] = { +@@ -3008,6 +3019,24 @@ finalize_it: + RETiRet; + } + ++void PrintQueueFullLog(qqueue_t *pThis, int flag) ++{ ++ struct timespec timeNow; ++ ++ clock_gettime(CLOCK_MONOTONIC, &timeNow); ++ if (timeNow.tv_sec - g_lastTime.tv_sec > TIME_OUT) { ++ if (flag == TIMEOUT_ENQUEUE_ZERO) { ++ sd_journal_print(LOG_NOTICE, "doEnqSingleObject: queue FULL - configured for immediate " ++ "discarding QueueSize=%d MaxQueueSize=%d sizeOnDisk=%lld " ++ "sizeOnDiskMax=%lld\n", pThis->iQueueSize, pThis->iMaxQueueSize, ++ pThis->tVars.disk.sizeOnDisk, pThis->sizeOnDiskMax); ++ } else if (flag == TIMEOUT_ENQUEUE_NONZERO) { ++ sd_journal_print(LOG_NOTICE, "doEnqSingleObject: queue FULL, iQueueSize=%d MaxQueueSize=%d - waiting %dms to drain.\n", ++ pThis->iQueueSize, pThis->iMaxQueueSize, pThis->toEnq); ++ } ++ g_lastTime.tv_sec = timeNow.tv_sec; ++ } ++} + + /* enqueue a single data object. + * Note that the queue mutex MUST already be locked when this function is called. +@@ -3105,12 +3134,14 @@ doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, smsg_t *pMsg) + "discarding QueueSize=%d MaxQueueSize=%d sizeOnDisk=%lld " + "sizeOnDiskMax=%lld\n", pThis->iQueueSize, pThis->iMaxQueueSize, + pThis->tVars.disk.sizeOnDisk, pThis->sizeOnDiskMax); ++ PrintQueueFullLog(pThis, TIMEOUT_ENQUEUE_ZERO); + STATSCOUNTER_INC(pThis->ctrFDscrd, pThis->mutCtrFDscrd); + msgDestruct(&pMsg); + ABORT_FINALIZE(RS_RET_QUEUE_FULL); + } else { + DBGOPRINT((obj_t*) pThis, "doEnqSingleObject: queue FULL - waiting %dms to drain.\n", + pThis->toEnq); ++ PrintQueueFullLog(pThis, TIMEOUT_ENQUEUE_NONZERO); + if(glbl.GetGlobalInputTermState()) { + DBGOPRINT((obj_t*) pThis, "doEnqSingleObject: queue FULL, discard due to " + "FORCE_TERM.\n"); +-- +2.23.0 + diff --git a/print-main-queue-info-to-journal-when-receive-USR1-signal.patch b/print-main-queue-info-to-journal-when-receive-USR1-signal.patch index e7baf383b3118ead78de88307de880a876232e2a..1924a7454b714f9e494c5e8bf2ce834f29fb4649 100644 --- a/print-main-queue-info-to-journal-when-receive-USR1-signal.patch +++ b/print-main-queue-info-to-journal-when-receive-USR1-signal.patch @@ -1,77 +1,83 @@ -From 27ee1b988a465e5f89e8a9234f4a01c34cab4387 Mon Sep 17 00:00:00 2001 -From: wangshouping -Date: Mon, 27 Apr 2020 08:53:18 -0400 -Subject: [PATCH] print main queue info to journal when receive USR1 signal -Signed-off-by: wangshouping ---- - tools/rsyslogd.c | 19 ++++++++++++++++++- - 1 files changed, 45 insertions(+), 1 deletion(-) -diff --git a/tools/rsyslogd.c b/tools/rsyslogd.c -index 7832693..ad92b20 100644 ---- a/tools/rsyslogd.c -+++ b/tools/rsyslogd.c -@@ -38,6 +38,7 @@ - #ifdef HAVE_LIBSYSTEMD - # include - #endif -+#include - - #include "rsyslog.h" - #include "wti.h" -@@ -181,6 +182,7 @@ void rsyslogdDoDie(int sig); - /* global data items */ - static int bChildDied; - static int bHadHUP; -+static int g_bRecordQueue; - static int doFork = 1; /* fork - run in daemon mode - read-only after startup */ - int bFinished = 0; /* used by termination signal handler, read-only except there - * is either 0 or the number of the signal that requested the -@@ -1267,8 +1269,13 @@ rsyslogdDebugSwitch(void) - dbgprintf("\n"); - debugging_on = 0; - } -+ - } - -+static void RsyslogdDebugQueue(void) -+{ -+ g_bRecordQueue = 1; -+} - - /* This is the main entry point into rsyslogd. Over time, we should try to - * modularize it a bit more... -@@ -1616,7 +1623,7 @@ initAll(int argc, char **argv) - hdlr_enable(SIGINT, rsyslogdDoDie); - hdlr_enable(SIGQUIT, rsyslogdDoDie); - } else { -- hdlr_enable(SIGUSR1, SIG_IGN); -+ hdlr_enable(SIGUSR1, RsyslogdDebugQueue); - hdlr_enable(SIGINT, SIG_IGN); - hdlr_enable(SIGQUIT, SIG_IGN); - } -@@ -1953,6 +1960,7 @@ mainloop(void) - sigaddset(&sigblockset, SIGTERM); - sigaddset(&sigblockset, SIGCHLD); - sigaddset(&sigblockset, SIGHUP); -+ sigaddset(&sigblockset, SIGUSR1); - - do { - processImInternal(); -@@ -1967,6 +1975,15 @@ mainloop(void) - doHUP(); - bHadHUP = 0; - } -+ if (g_bRecordQueue) { -+ if (pMsgQueue != NULL) { -+ sd_journal_print(LOG_NOTICE, "main queue size information: current QueueSize=%d MaxQueueSize=%d\n", -+ pMsgQueue->iQueueSize, pMsgQueue->iMaxQueueSize); -+ } else { -+ sd_journal_print(LOG_NOTICE, "main queue size information: pMsgQueue is NULL!\n"); -+ } -+ g_bRecordQueue = 0; -+ } - - if(bFinished) - break; /* exit as quickly as possible */ --- -2.19.1 \ No newline at end of file +From 27ee1b988a465e5f89e8a9234f4a01c34cab4387 Mon Sep 17 00:00:00 2001 +From: wangshouping +Date: Mon, 27 Apr 2020 08:53:18 -0400 +Subject: [PATCH] print main queue info to journal when receive USR1 signal +Signed-off-by: wangshouping + +V-2: add macro control for systemd/sd-journal.h +Signed-off-by: pengyi37 + +--- + tools/rsyslogd.c | 19 ++++++++++++++++++- + 1 file changed, 18 insertions(+), 1 deletion(-) + +diff --git a/tools/rsyslogd.c b/tools/rsyslogd.c +index f1eea07..657f4de 100644 +--- a/tools/rsyslogd.c ++++ b/tools/rsyslogd.c +@@ -36,6 +36,7 @@ + #endif + #ifdef HAVE_LIBSYSTEMD + # include ++# include + #endif + + #include "rsyslog.h" +@@ -180,6 +181,7 @@ void rsyslogdDoDie(int sig); + /* global data items */ + static int bChildDied; + static int bHadHUP; ++static int g_bRecordQueue; + static int doFork = 1; /* fork - run in daemon mode - read-only after startup */ + int bFinished = 0; /* used by termination signal handler, read-only except there + * is either 0 or the number of the signal that requested the +@@ -1269,8 +1271,13 @@ rsyslogdDebugSwitch(void) + dbgprintf("\n"); + debugging_on = 0; + } ++ + } + ++static void RsyslogdDebugQueue(void) ++{ ++ g_bRecordQueue = 1; ++} + + /* This is the main entry point into rsyslogd. Over time, we should try to + * modularize it a bit more... +@@ -1618,7 +1625,7 @@ initAll(int argc, char **argv) + hdlr_enable(SIGINT, rsyslogdDoDie); + hdlr_enable(SIGQUIT, rsyslogdDoDie); + } else { +- hdlr_enable(SIGUSR1, SIG_IGN); ++ hdlr_enable(SIGUSR1, RsyslogdDebugQueue); + hdlr_enable(SIGINT, SIG_IGN); + hdlr_enable(SIGQUIT, SIG_IGN); + } +@@ -1956,6 +1963,7 @@ mainloop(void) + sigaddset(&sigblockset, SIGTERM); + sigaddset(&sigblockset, SIGCHLD); + sigaddset(&sigblockset, SIGHUP); ++ sigaddset(&sigblockset, SIGUSR1); + + do { + processImInternal(); +@@ -1970,6 +1978,15 @@ mainloop(void) + doHUP(); + bHadHUP = 0; + } ++ if (g_bRecordQueue) { ++ if (pMsgQueue != NULL) { ++ sd_journal_print(LOG_NOTICE, "main queue size information: current QueueSize=%d MaxQueueSize=%d\n", ++ pMsgQueue->iQueueSize, pMsgQueue->iMaxQueueSize); ++ } else { ++ sd_journal_print(LOG_NOTICE, "main queue size information: pMsgQueue is NULL!\n"); ++ } ++ g_bRecordQueue = 0; ++ } + + if(bFinished) + break; /* exit as quickly as possible */ +-- +2.23.0 + diff --git a/rsyslog.spec b/rsyslog.spec index bb715915e20215a339858efd36ae31ade16d28fc..980543d3eb5a818c5081368fc9312bfc53eedb23 100644 --- a/rsyslog.spec +++ b/rsyslog.spec @@ -7,7 +7,7 @@ Name: rsyslog Version: 8.2110.0 -Release: 12 +Release: 13 Summary: The rocket-fast system for log processing License: (GPLv3+ and ASL 2.0) URL: http://www.rsyslog.com/ @@ -41,6 +41,11 @@ Patch6005: backport-tcpsrv-do-not-decrease-number-of-to-be-processed-fds.pa Patch6006: backport-imptcp-bugfix-worker-thread-starvation-on-extreme-tr.patch Patch6007: backport-Fix-memory-leak-when-globally-de-initialize-GnuTLS.patch Patch6008: backport-Fix-memory-leak-when-free-action-worker-data-table.patch +Patch6009: backport-Fix-memory-leak-when-SetString.patch +Patch6010: backport-core-bugfix-correct-local-host-name-after-config-processing.patch +Patch6011: backport-core-bugfix-local-hostname-invalid-if-no-global-config-object-given.patch +Patch6012: backport-Simplified-and-fixed-IPv4-digit-detection.patch +Patch6013: backport-tcpsrv-cleanup-remove-commented-out-code.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 @@ -503,6 +508,12 @@ done %{_mandir}/man1/rscryutil.1.gz %changelog +* Sat Dec 17 2022 pengyi - 8.2110.0-13 +- Type:NA +- ID:NA +- SUG:NA +- DESC: backport patches from upstream + * Thu Oct 13 2022 huangduirong - 8.2110.0-12 - Type:NA - ID:NA