sync PR-88
This commit is contained in:
parent
f7574c0606
commit
a2e3149e9b
32
backport-Fix-memory-leak-when-SetString.patch
Normal file
32
backport-Fix-memory-leak-when-SetString.patch
Normal file
@ -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
|
||||
218
backport-Simplified-and-fixed-IPv4-digit-detection.patch
Normal file
218
backport-Simplified-and-fixed-IPv4-digit-detection.patch
Normal file
@ -0,0 +1,218 @@
|
||||
From a335ec06f0897a71356afee3362f67e68b91a3de Mon Sep 17 00:00:00 2001
|
||||
From: Andre lorbach <alorbach@adiscon.com>
|
||||
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 <stdio.h>
|
||||
+#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -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
|
||||
@ -0,0 +1,258 @@
|
||||
From ba00a9f25293f72137c9a85010276cca014ae7f0 Mon Sep 17 00:00:00 2001
|
||||
From: Rainer Gerhards <rgerhards@adiscon.com>
|
||||
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
|
||||
@ -0,0 +1,45 @@
|
||||
From e2beca531157a4c0a27bcdda689bc53373e305b3 Mon Sep 17 00:00:00 2001
|
||||
From: Rainer Gerhards <rgerhards@adiscon.com>
|
||||
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
|
||||
39
backport-tcpsrv-cleanup-remove-commented-out-code.patch
Normal file
39
backport-tcpsrv-cleanup-remove-commented-out-code.patch
Normal file
@ -0,0 +1,39 @@
|
||||
From 22bef1c86200e594fd6d5d42fb10647d1303874f Mon Sep 17 00:00:00 2001
|
||||
From: Rainer Gerhards <rgerhards@adiscon.com>
|
||||
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
|
||||
@ -3,22 +3,29 @@ From: wangshouping <wangshouping@huawei.com>
|
||||
Date: Mon, 27 Apr 2020 08:53:18 -0400
|
||||
Subject: [PATCH] print main queue info to journal when queue full
|
||||
Signed-off-by: wangshouping <wangshouping@huawei.com>
|
||||
|
||||
V-2: add macro control for systemd/sd-journal.h
|
||||
Signed-off-by: pengyi37 <pengyi37@huawei.com>
|
||||
|
||||
---
|
||||
runtime/queue.c | 27 +++++++++++++++++++++++++++
|
||||
1 files changed, 45 insertions(+), 1 deletion(-)
|
||||
runtime/queue.c | 31 +++++++++++++++++++++++++++++++
|
||||
1 file changed, 31 insertions(+)
|
||||
|
||||
diff --git a/runtime/queue.c b/runtime/queue.c
|
||||
index e988e44..9faf5aa 100644
|
||||
index 3083fb9..b3fdd51 100644
|
||||
--- a/runtime/queue.c
|
||||
+++ b/runtime/queue.c
|
||||
@@ -47,6 +47,7 @@
|
||||
@@ -47,6 +47,9 @@
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <sys/vfs.h>
|
||||
+#include <systemd/sd-journal.h>
|
||||
+#ifdef HAVE_LIBSYSTEMD
|
||||
+# include <systemd/sd-journal.h>
|
||||
+#endif
|
||||
|
||||
#include "rsyslog.h"
|
||||
#include "queue.h"
|
||||
@@ -116,6 +117,14 @@ rsRetVal qqueueSetSpoolDir(qqueue_t *pThis, uchar *pszSpoolDir, int lenSpoolDir)
|
||||
@@ -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
|
||||
@ -33,7 +40,7 @@ index e988e44..9faf5aa 100644
|
||||
|
||||
/* tables for interfacing with the v6 config system */
|
||||
static struct cnfparamdescr cnfpdescr[] = {
|
||||
@@ -2985,6 +2992,24 @@ finalize_it:
|
||||
@@ -3008,6 +3019,24 @@ finalize_it:
|
||||
RETiRet;
|
||||
}
|
||||
|
||||
@ -58,7 +65,7 @@ index e988e44..9faf5aa 100644
|
||||
|
||||
/* 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)
|
||||
@@ -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);
|
||||
@ -74,4 +81,5 @@ index e988e44..9faf5aa 100644
|
||||
DBGOPRINT((obj_t*) pThis, "doEnqSingleObject: queue FULL, discard due to "
|
||||
"FORCE_TERM.\n");
|
||||
--
|
||||
2.19.1
|
||||
2.23.0
|
||||
|
||||
|
||||
@ -3,22 +3,27 @@ From: wangshouping <wangshouping@huawei.com>
|
||||
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 <wangshouping@huawei.com>
|
||||
|
||||
V-2: add macro control for systemd/sd-journal.h
|
||||
Signed-off-by: pengyi37 <pengyi37@huawei.com>
|
||||
|
||||
---
|
||||
tools/rsyslogd.c | 19 ++++++++++++++++++-
|
||||
1 files changed, 45 insertions(+), 1 deletion(-)
|
||||
1 file changed, 18 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tools/rsyslogd.c b/tools/rsyslogd.c
|
||||
index 7832693..ad92b20 100644
|
||||
index f1eea07..657f4de 100644
|
||||
--- a/tools/rsyslogd.c
|
||||
+++ b/tools/rsyslogd.c
|
||||
@@ -38,6 +38,7 @@
|
||||
@@ -36,6 +36,7 @@
|
||||
#endif
|
||||
#ifdef HAVE_LIBSYSTEMD
|
||||
# include <systemd/sd-daemon.h>
|
||||
+# include <systemd/sd-journal.h>
|
||||
#endif
|
||||
+#include <systemd/sd-journal.h>
|
||||
|
||||
#include "rsyslog.h"
|
||||
#include "wti.h"
|
||||
@@ -181,6 +182,7 @@ void rsyslogdDoDie(int sig);
|
||||
@@ -180,6 +181,7 @@ void rsyslogdDoDie(int sig);
|
||||
/* global data items */
|
||||
static int bChildDied;
|
||||
static int bHadHUP;
|
||||
@ -26,7 +31,7 @@ index 7832693..ad92b20 100644
|
||||
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)
|
||||
@@ -1269,8 +1271,13 @@ rsyslogdDebugSwitch(void)
|
||||
dbgprintf("\n");
|
||||
debugging_on = 0;
|
||||
}
|
||||
@ -40,7 +45,7 @@ index 7832693..ad92b20 100644
|
||||
|
||||
/* 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)
|
||||
@@ -1618,7 +1625,7 @@ initAll(int argc, char **argv)
|
||||
hdlr_enable(SIGINT, rsyslogdDoDie);
|
||||
hdlr_enable(SIGQUIT, rsyslogdDoDie);
|
||||
} else {
|
||||
@ -49,7 +54,7 @@ index 7832693..ad92b20 100644
|
||||
hdlr_enable(SIGINT, SIG_IGN);
|
||||
hdlr_enable(SIGQUIT, SIG_IGN);
|
||||
}
|
||||
@@ -1953,6 +1960,7 @@ mainloop(void)
|
||||
@@ -1956,6 +1963,7 @@ mainloop(void)
|
||||
sigaddset(&sigblockset, SIGTERM);
|
||||
sigaddset(&sigblockset, SIGCHLD);
|
||||
sigaddset(&sigblockset, SIGHUP);
|
||||
@ -57,7 +62,7 @@ index 7832693..ad92b20 100644
|
||||
|
||||
do {
|
||||
processImInternal();
|
||||
@@ -1967,6 +1975,15 @@ mainloop(void)
|
||||
@@ -1970,6 +1978,15 @@ mainloop(void)
|
||||
doHUP();
|
||||
bHadHUP = 0;
|
||||
}
|
||||
@ -74,4 +79,5 @@ index 7832693..ad92b20 100644
|
||||
if(bFinished)
|
||||
break; /* exit as quickly as possible */
|
||||
--
|
||||
2.19.1
|
||||
2.23.0
|
||||
|
||||
|
||||
25
rsyslog.spec
25
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
|
||||
@ -353,6 +358,18 @@ rm -f %{buildroot}%{_libdir}/rsyslog/liboverride_gethostname_nonfqdn.so
|
||||
%delete_la
|
||||
|
||||
%pre
|
||||
# Delete file and package upgrades concurrently, Cause the upgrade to fail.
|
||||
# so, empty file instead of deleting file
|
||||
if [ -f /etc/cron.hourly/logrotate ];then
|
||||
sed -i s/'^if[[:blank:]]*\[[[:blank:]]*-f[[:blank:]]*\/etc\/logrotate.d\/rsyslog[[:blank:]]*\];then$'/'if \[ -s \/etc\/logrotate.d\/rsyslog \];then'/g /etc/cron.hourly/logrotate
|
||||
sed -i s/'^[[:blank:]]*rm[[:blank:]]*-f[[:blank:]]*\/etc\/logrotate.d\/rsyslog$'/' > \/etc\/logrotate.d\/rsyslog'/g /etc/cron.hourly/logrotate
|
||||
# Delay 2s, wait for /etc/cron.hourly/logrotate delete file execution to complete
|
||||
sleep 2
|
||||
if [ ! -f /etc/logrotate.d/rsyslog ]; then
|
||||
touch /etc/logrotate.d/rsyslog
|
||||
chmod 644 /etc/logrotate.d/rsyslog
|
||||
fi
|
||||
fi
|
||||
|
||||
%post
|
||||
for n in /var/log/{messages,secure,maillog,spooler}
|
||||
@ -503,6 +520,12 @@ done
|
||||
%{_mandir}/man1/rscryutil.1.gz
|
||||
|
||||
%changelog
|
||||
* Sat Dec 17 2022 pengyi <pengyi37@huawei.com> - 8.2110.0-13
|
||||
- Type:NA
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC: backport patches from upstream
|
||||
|
||||
* Thu Oct 13 2022 huangduirong <huangduirong@huawei.com> - 8.2110.0-12
|
||||
- Type:NA
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user