From 81a10f11a90e23e4f4ebc0bc00b310803405ba3e Mon Sep 17 00:00:00 2001 From: Qiumiao Zhang Date: Wed, 19 Jun 2024 03:33:31 +0000 Subject: [PATCH] backport patches from upstream Signed-off-by: Qiumiao Zhang --- ...remove-state-file-on-file-delete-fix.patch | 29 +++++++ ...rry-out-actual-action-when-writing-t.patch | 85 +++++++++++++++++++ rsyslog.spec | 11 ++- 3 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 backport-imfile-remove-state-file-on-file-delete-fix.patch create mode 100644 backport-omfile-do-not-carry-out-actual-action-when-writing-t.patch diff --git a/backport-imfile-remove-state-file-on-file-delete-fix.patch b/backport-imfile-remove-state-file-on-file-delete-fix.patch new file mode 100644 index 0000000..ab309b9 --- /dev/null +++ b/backport-imfile-remove-state-file-on-file-delete-fix.patch @@ -0,0 +1,29 @@ +From eadb0b6d93867c26a26f0a5effa7332420d319cc Mon Sep 17 00:00:00 2001 +From: alakatos +Date: Fri, 3 Nov 2023 10:24:15 +0100 +Subject: [PATCH] imfile: remove state file on file delete fix + +The state file would remain in the working directory +after shutdown, even though deleteStateOnfileDelete is +set to "on" and the monitored file was removed. + +Fixes #5258 + +Reference:https://github.com/rsyslog/rsyslog/commit/eadb0b6d93867c26a26f0a5effa7332420d319cc +Conflict:NA +--- + plugins/imfile/imfile.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c +index 5febd6db67..3b0bb10698 100644 +--- a/plugins/imfile/imfile.c ++++ b/plugins/imfile/imfile.c +@@ -1153,6 +1153,7 @@ fs_node_destroy(fs_node_t *const node) + DBGPRINTF("node destroy: %p edges:\n", node); + + for(edge = node->edges ; edge != NULL ; ) { ++ detect_updates(edge); + fs_node_destroy(edge->node); + fs_edge_t *const toDel = edge; + edge = edge->next; diff --git a/backport-omfile-do-not-carry-out-actual-action-when-writing-t.patch b/backport-omfile-do-not-carry-out-actual-action-when-writing-t.patch new file mode 100644 index 0000000..19d70e7 --- /dev/null +++ b/backport-omfile-do-not-carry-out-actual-action-when-writing-t.patch @@ -0,0 +1,85 @@ +From 25224fb536488ae63e6addd2c9005bc2b8dc126a Mon Sep 17 00:00:00 2001 +From: Rainer Gerhards +Date: Wed, 21 Feb 2024 09:31:00 +0100 +Subject: [PATCH] omfile: do not carry out actual action when writing to + /dev/null + +In some use cases omfile is configured to write to /dev/null. This seems +primarily be done because of statistics gathering but maybe some other +scenarios. We now add conditional logic to not do any actual omfile +action when the target file is /dev/null. + +Note: this check only works on static file names. When /dev/null is +evaluated as part of dynafile, it will be handled just in the regular +case like before this patch. + +Reference:https://github.com/rsyslog/rsyslog/commit/25224fb536488ae63e6addd2c9005bc2b8dc126a +Conflict:"* Copyright 2007-2018 Adiscon GmbH." in tools/omfile.c +--- + tools/omfile.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +diff --git a/tools/omfile.c b/tools/omfile.c +index 64578c4..e18809a 100644 +--- a/tools/omfile.c ++++ b/tools/omfile.c +@@ -17,7 +17,7 @@ + * pipes. These have been moved to ompipe, to reduced the entanglement + * between the two different functionalities. -- rgerhards + * +- * Copyright 2007-2018 Adiscon GmbH. ++ * Copyright 2007-2024 Adiscon GmbH. + * + * This file is part of rsyslog. + * +@@ -139,6 +139,7 @@ typedef struct _instanceData { + strm_t *pStrm; /* our output stream */ + short nInactive; /* number of minutes not writen (STATIC files only) */ + char bDynamicName; /* 0 - static name, 1 - dynamic name (with properties) */ ++ int isDevNull; /* do we "write" to /dev/null? - if so, do nothing */ + int fCreateMode; /* file creation mode for open() */ + int fDirCreateMode; /* creation mode for mkdir() */ + int bCreateDirs; /* auto-create directories? */ +@@ -1086,6 +1087,11 @@ BEGINcommitTransaction + instanceData *__restrict__ const pData = pWrkrData->pData; + unsigned i; + CODESTARTcommitTransaction ++ ++ if(pData->isDevNull) { ++ goto terminate; ++ } ++ + pthread_mutex_lock(&pData->mutWrite); + + for(i = 0 ; i < nParams ; ++i) { +@@ -1110,6 +1116,8 @@ finalize_it: + iRet = (pData->bDynamicName && runModConf->bDynafileDoNotSuspend) ? + RS_RET_OK : RS_RET_SUSPENDED; + } ++ ++terminate: + ENDcommitTransaction + + +@@ -1139,6 +1147,7 @@ setInstParamDefaults(instanceData *__restrict__ const pData) + pData->useSigprov = 0; + pData->useCryprov = 0; + pData->iCloseTimeout = -1; ++ pData->isDevNull = 0; + } + + +@@ -1377,6 +1386,10 @@ CODESTARTnewActInst + ABORT_FINALIZE(RS_RET_MISSING_CNFPARAMS); + } + ++ if(!strcmp((const char*) pData->fname, "/dev/null")) { ++ pData->isDevNull = 1; ++ } ++ + if(pData->sigprovName != NULL) { + initSigprov(pData, lst); + } +-- +2.19.1 + diff --git a/rsyslog.spec b/rsyslog.spec index 930bee4..5109fe9 100644 --- a/rsyslog.spec +++ b/rsyslog.spec @@ -7,7 +7,7 @@ Name: rsyslog Version: 8.2110.0 -Release: 19 +Release: 20 Summary: The rocket-fast system for log processing License: (GPLv3+ and ASL 2.0) URL: http://www.rsyslog.com/ @@ -77,6 +77,8 @@ Patch6043: backport-tcpflood-bugfix-TCP-sending-was-not-implemented-properl Patch6044: backport-tcpflood-bugfix-plain-tcp-send-error-not-properly-reported.patch Patch6045: backport-fix-startup-issue-on-modern-systemd-systems.patch Patch6046: backport-tcp-net-subsystem-handle-data-race-gracefully.patch +Patch6047: backport-imfile-remove-state-file-on-file-delete-fix.patch +Patch6048: backport-omfile-do-not-carry-out-actual-action-when-writing-t.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 @@ -551,6 +553,13 @@ done %{_mandir}/man1/rscryutil.1.gz %changelog +* Wed Jun 19 2024 zhangqiumiao - 8.2110.0-20 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:imfile: remove state file on file delete fix + omfile: do not carry out actual action when writing to /dev/null + * Wed Mar 20 2024 zhangqiumiao - 8.2110.0-19 - Type:bugfix - CVE:NA -- Gitee