summaryrefslogtreecommitdiffstats
path: root/tests/imklog_permitnonkernelfacility_root.sh
blob: 16e8b90a6d4069a2c6f1557933510bfc599c21c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# add 2017-07-18 by Pascal Withopf, released under ASL 2.0
echo \[imklog_permitnonkernelfacility_root.sh\]: test parameter permitnonkernelfacility
echo This test must be run as root with no other active syslogd
if [ "$EUID" -ne 0 ]; then
    exit 77 # Not root, skip this test
fi
service rsyslog stop
. ${srcdir:=.}/diag.sh init
generate_conf
add_conf '
module(load="../plugins/imklog/.libs/imklog" permitnonkernelfacility="on")

template(name="outfmt" type="string" string="%msg:57:16%: -%pri%-\n")

:msg, contains, "msgnum" action(type="omfile" template="outfmt" file=`echo $RSYSLOG_OUT_LOG`)
'
startup
echo "<115>Mar 10 01:00:00 172.20.245.8 tag: msgnum:1" > /dev/kmsg
echo "<115>Mar 10 01:00:00 172.20.245.8 tag: msgnum:1"
sleep 2
shutdown_when_empty
wait_shutdown
echo 'Mar 10 01:00:00 172.20.245.8 tag: msgnum:1: -115-' | cmp - $RSYSLOG_OUT_LOG
if [ ! $? -eq 0 ]; then
  echo "invalid response generated, $RSYSLOG_OUT_LOG is:"
  cat $RSYSLOG_OUT_LOG
  error_exit  1
fi;

service rsyslog start
exit_test