syslog/syslog-lib.sh: Match rsyslog config written by RainerScript

Message ID 1539249654-24401-1-git-send-email-yangx.jy@cn.fujitsu.com
State Accepted
Headers show
Series
  • syslog/syslog-lib.sh: Match rsyslog config written by RainerScript
Related show

Commit Message

Xiao Yang Oct. 11, 2018, 9:20 a.m.
Since rsyslog commit 3b55048094d759adf8162f0829f239e115ebf2c0, rsyslog
by default deletes log socket during restart, unless socket is provided
by systemd.

If default rsyslog config written by RainerScript uses imjournal module
(e.g. module(load="imjournal"...) and doesn't specify $SystemLogSocketName,
syslog-lib.sh cannot match imjournal module and just write imuxsock module
into the rsyslog.conf constructed by test.  In this case, "/dev/log" is
owned by journald but rsyslog deletes it as its default log socket after
testing.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 testcases/kernel/syscalls/syslog/syslog-lib.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Stancek Oct. 12, 2018, 1:02 p.m. | #1
----- Original Message -----
> Since rsyslog commit 3b55048094d759adf8162f0829f239e115ebf2c0, rsyslog
> by default deletes log socket during restart, unless socket is provided
> by systemd.
> 
> If default rsyslog config written by RainerScript uses imjournal module
> (e.g. module(load="imjournal"...) and doesn't specify $SystemLogSocketName,
> syslog-lib.sh cannot match imjournal module and just write imuxsock module
> into the rsyslog.conf constructed by test.  In this case, "/dev/log" is
> owned by journald but rsyslog deletes it as its default log socket after
> testing.
> 
> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>

Pushed with added comment what patterns is the grep targetting.

Thanks,
Jan

Patch

diff --git a/testcases/kernel/syscalls/syslog/syslog-lib.sh b/testcases/kernel/syscalls/syslog/syslog-lib.sh
index 35c13da..30c797a 100755
--- a/testcases/kernel/syscalls/syslog/syslog-lib.sh
+++ b/testcases/kernel/syscalls/syslog/syslog-lib.sh
@@ -71,7 +71,7 @@  setup()
 		CONFIG_FILE="/etc/syslog-ng/syslog-ng.conf"
 	elif [ "$SYSLOG_DAEMON" = "rsyslog" ]; then
 		CONFIG_FILE="/etc/rsyslog.conf"
-		if grep -q -r '^\$ModLoad[[:space:]]*imjournal' /etc/rsyslog.conf /etc/rsyslog.d/ ; then
+		if grep -qri '^[^#].*load.*imjournal' /etc/rsyslog.conf /etc/rsyslog.d/ ; then
 			systemd_journal=$(grep -Ehoi "^[^#].*(imjournal|workdirectory).*" -r /etc/rsyslog.conf /etc/rsyslog.d/)
 			RSYSLOG_CONFIG=$(cat <<EOF
 $systemd_journal