File 0001-imfile-Remove-inotify-watch-descriptor-on-inode-chan.patch of Package rsyslog.25255
From 46c79edc53cdfa8e73c4690d39017315f9c888aa Mon Sep 17 00:00:00 2001
From: Masahiro Matsuya <mmatsuya@redhat.com>
Date: Wed, 9 Feb 2022 16:36:24 +0900
Subject: [PATCH] imfile: Remove inotify watch descriptor on inode change
detected
---
plugins/imfile/imfile.c | 1 +
tests/imfile-rename.sh | 17 +++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
index 29fe8155e..f79c10fb4 100644
--- a/plugins/imfile/imfile.c
+++ b/plugins/imfile/imfile.c
@@ -1040,6 +1040,7 @@ act_obj_destroy(act_obj_t *const act, const int is_deleted)
}
#ifdef HAVE_INOTIFY_INIT
if(act->wd != -1) {
+ inotify_rm_watch(ino_fd, act->wd);
wdmapDel(act->wd);
}
#endif
diff --git a/tests/imfile-rename.sh b/tests/imfile-rename.sh
index 28ea69dd4..6d249d336 100755
--- a/tests/imfile-rename.sh
+++ b/tests/imfile-rename.sh
@@ -42,6 +42,11 @@ if $msg contains "msgnum:" then
file=`echo $RSYSLOG_OUT_LOG`
template="outfmt"
)
+if $msg contains "imfile:" then
+ action(
+ type="omfile"
+ file="'$RSYSLOG_DYNNAME.errmsgs'"
+ )
'
# generate input file first.
@@ -58,6 +63,18 @@ wait_file_lines $RSYSLOG_OUT_LOG $TESTMESSAGES $RETRIES
mv $RSYSLOG_DYNNAME.input.1.log rsyslog.input.2.log
./msleep 500
+
+# Write into the renamed file
+echo 'testmessage1
+testmessage2' >> rsyslog.input.2.log
+
+./msleep 500
+
+if grep "imfile: internal error? inotify provided watch descriptor" < "$RSYSLOG_DYNNAME.errmsgs" ; then
+ echo "Error: inotify event from renamed file"
+ exit 1
+fi
+
# generate some more input into moved file
./inputfilegen -m $TESTMESSAGES -i $TESTMESSAGES >> $RSYSLOG_DYNNAME.input.2.log
ls -l $RSYSLOG_DYNNAME.input*
--
2.35.3