Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP2:Update
rsyslog
0001-fixing-the-deleteStateOnFileDelete-option....
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-fixing-the-deleteStateOnFileDelete-option.patch of Package rsyslog
From fca8e14d65019ee1b814c4ed16ec7ff04de30809 Mon Sep 17 00:00:00 2001 From: pearse <pearse.doolin@imperva.com> Date: Tue, 13 Jul 2021 00:12:22 +0000 Subject: [PATCH] fixing the deleteStateOnFileDelete option --- plugins/imfile/imfile.c | 2 +- tests/Makefile.am | 4 ++++ tests/imfile-statefile-delete.sh | 36 +++++++++++++++++++++++++++++ tests/imfile-statefile-no-delete.sh | 36 +++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100755 tests/imfile-statefile-delete.sh create mode 100755 tests/imfile-statefile-no-delete.sh diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c index db161cc49..c7bdac8d9 100644 --- a/plugins/imfile/imfile.c +++ b/plugins/imfile/imfile.c @@ -996,7 +996,7 @@ act_obj_destroy(act_obj_t *const act, const int is_deleted) pollFile(act); /* get any left-over data */ if(inst->bRMStateOnDel) { statefn = getStateFileName(act, statefile, sizeof(statefile)); - getFullStateFileName(statefn, "", toDel, sizeof(toDel)); // TODO: check! + getFullStateFileName(statefn, act->file_id, toDel, sizeof(toDel)); // TODO: check! statefn = toDel; } persistStrmState(act); diff --git a/tests/Makefile.am b/tests/Makefile.am index 39f7e60b3..da43e73ed 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1441,6 +1441,8 @@ TESTS += \ imfile-statefile-no-file_id.sh \ imfile-statefile-no-file_id-TO-file_id.sh \ imfile-statefile-directory.sh \ + imfile-statefile-delete.sh \ + imfile-statefile-no-delete.sh \ imfile-persist-state-1.sh \ imfile-freshStartTail1.sh \ imfile-freshStartTail2.sh \ @@ -2383,6 +2385,8 @@ EXTRA_DIST= \ imfile-statefile-no-file_id.sh \ imfile-statefile-no-file_id-TO-file_id.sh \ imfile-statefile-directory.sh \ + imfile-statefile-delete.sh \ + imfile-statefile-no-delete.sh \ imfile-persist-state-1.sh \ imfile-freshStartTail1.sh \ imfile-freshStartTail2.sh \ diff --git a/tests/imfile-statefile-delete.sh b/tests/imfile-statefile-delete.sh new file mode 100755 index 000000000..4d6a6059b --- /dev/null +++ b/tests/imfile-statefile-delete.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# added 2019-02-28 +# This is part of the rsyslog testbench, licensed under ASL 2.0 +. ${srcdir:=.}/diag.sh init +export TESTMESSAGES=1000 +export TESTMESSAGESFULL=999 +export RETRIES=50 +generate_conf +add_conf ' +global(workDirectory="'${RSYSLOG_DYNNAME}'.spool") +module(load="../plugins/imfile/.libs/imfile" mode="inotify" PollingInterval="1") +input(type="imfile" tag="file:" file="./'$RSYSLOG_DYNNAME'.input") + +template(name="outfmt" type="string" string="%msg:F,58:2%\n") +if $msg contains "msgnum:" then + action(type="omfile" file=`echo $RSYSLOG_OUT_LOG` template="outfmt") +' +./inputfilegen -m $TESTMESSAGES > $RSYSLOG_DYNNAME.input +inode=$(get_inode "$RSYSLOG_DYNNAME.input") +startup +wait_file_lines $RSYSLOG_OUT_LOG $TESTMESSAGES $RETRIES +rm $RSYSLOG_DYNNAME.input +sleep_time_ms=0 +while ls $RSYSLOG_DYNNAME.spool/imfile-state:$inode:* 1> /dev/null 2>&1; do + ./msleep 10 + ((sleep_time_ms+=10)) + if [ $sleep_time_ms -ge 30000 ]; then + printf 'FAIL: state file still exists when it should have been deleted\nspool dir is:\n' + ls -l $RSYSLOG_DYNNAME.spool + error_exit 1 + fi +done +shutdown_when_empty +wait_shutdown +seq_check 0 $TESTMESSAGESFULL # check we got the message correctly +exit_test diff --git a/tests/imfile-statefile-no-delete.sh b/tests/imfile-statefile-no-delete.sh new file mode 100755 index 000000000..309b5d400 --- /dev/null +++ b/tests/imfile-statefile-no-delete.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Added 2019-02-28 +# This is part of the rsyslog testbench, licensed under ASL 2.0 +. ${srcdir:=.}/diag.sh init +export TESTMESSAGES=1000 +export TESTMESSAGESFULL=999 +export RETRIES=50 + +generate_conf +add_conf ' +global(workDirectory="'${RSYSLOG_DYNNAME}'.spool") +module(load="../plugins/imfile/.libs/imfile" mode="inotify" PollingInterval="1") +input(type="imfile" tag="file:" file="./'$RSYSLOG_DYNNAME'.input" deleteStateOnFileDelete="off") + +template(name="outfmt" type="string" string="%msg:F,58:2%\n") +if $msg contains "msgnum:" then + action(type="omfile" file=`echo $RSYSLOG_OUT_LOG` template="outfmt") +' +./inputfilegen -m $TESTMESSAGES > $RSYSLOG_DYNNAME.input +inode=$(get_inode "$RSYSLOG_DYNNAME.input") +startup +wait_file_lines $RSYSLOG_OUT_LOG $TESTMESSAGES $RETRIES +rm $RSYSLOG_DYNNAME.input +# sleep a little to give rsyslog a chance to notice the deleted file +./msleep 2000 + +shutdown_when_empty +wait_shutdown +seq_check 0 $TESTMESSAGESFULL # check we got the message correctly +if ! ls $RSYSLOG_DYNNAME.spool/imfile-state:$inode:* 1> /dev/null 2>&1; then + printf 'FAIL: state file was deleted when it should not have been\nspool dir is:\n' + ls -l $RSYSLOG_DYNNAME.spool + error_exit 1 +fi + +exit_test -- 2.41.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor