|
| 1 | +#!/bin/bash |
| 2 | +# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_sle,multi_platform_almalinux |
| 3 | + |
| 4 | +# Declare variables used for the tests and define the create_rsyslog_test_logs function |
| 5 | +source $SHARED/rsyslog_log_utils.sh |
| 6 | + |
| 7 | +{{% if ATTRIBUTE == "owner" %}} |
| 8 | +CHATTR="chown" |
| 9 | +ATTR_VALUE="root" |
| 10 | +ATTR_INCORRECT_VALUE="cac_testuser" |
| 11 | +useradd $ATTR_INCORRECT_VALUE |
| 12 | +{{% elif ATTRIBUTE == "groupowner" %}} |
| 13 | +CHATTR="chgrp" |
| 14 | +ATTR_VALUE="root" |
| 15 | +ATTR_INCORRECT_VALUE="cac_testgroup" |
| 16 | +groupadd $ATTR_INCORRECT_VALUE |
| 17 | +{{% else %}} |
| 18 | +CHATTR="chmod" |
| 19 | +ATTR_VALUE="0640" |
| 20 | +ATTR_INCORRECT_VALUE="0666" |
| 21 | +{{% endif %}} |
| 22 | + |
| 23 | +touch /var/log/messages |
| 24 | + |
| 25 | +$CHATTR $ATTR_VALUE /var/log/maillog |
| 26 | +$CHATTR $ATTR_INCORRECT_VALUE /var/log/messages |
| 27 | + |
| 28 | +cat <<EOF >$RSYSLOG_CONF |
| 29 | +# rsyslog configuration file |
| 30 | +
|
| 31 | +# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html |
| 32 | +# or latest version online at http://www.rsyslog.com/doc/rsyslog_conf.html |
| 33 | +# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html |
| 34 | +
|
| 35 | +#### GLOBAL DIRECTIVES #### |
| 36 | +
|
| 37 | +# Where to place auxiliary files |
| 38 | +global(workDirectory="/var/lib/rsyslog") |
| 39 | +
|
| 40 | +#### MODULES #### |
| 41 | +
|
| 42 | +# Use default timestamp format |
| 43 | +module(load="builtin:omfile" Template="RSYSLOG_TraditionalFileFormat") |
| 44 | +
|
| 45 | +module(load="imuxsock" # provides support for local system logging (e.g. via logger command) |
| 46 | + SysSock.Use="off") # Turn off message reception via local log socket; |
| 47 | + # local messages are retrieved through imjournal now. |
| 48 | +module(load="imjournal" # provides access to the systemd journal |
| 49 | + UsePid="system" # PID nummber is retrieved as the ID of the process the journal entry originates from |
| 50 | + FileCreateMode="0644" # Set the access permissions for the state file |
| 51 | + StateFile="imjournal.state") # File to store the position in the journal |
| 52 | +
|
| 53 | +# Include all config files in /etc/rsyslog.d/ |
| 54 | +include(file="/etc/rsyslog.d/*.conf" mode="optional") |
| 55 | +
|
| 56 | +#module(load="imklog") # reads kernel messages (the same are read from journald) |
| 57 | +#module(load="immark") # provides --MARK-- message capability |
| 58 | +
|
| 59 | +# Provides UDP syslog reception |
| 60 | +# for parameters see http://www.rsyslog.com/doc/imudp.html |
| 61 | +#module(load="imudp") # needs to be done just once |
| 62 | +#input(type="imudp" port="514") |
| 63 | +
|
| 64 | +# Provides TCP syslog reception |
| 65 | +# for parameters see http://www.rsyslog.com/doc/imtcp.html |
| 66 | +#module(load="imtcp") # needs to be done just once |
| 67 | +#input(type="imtcp" port="514") |
| 68 | +
|
| 69 | +#### RULES #### |
| 70 | +
|
| 71 | +# Log all kernel messages to the console. |
| 72 | +# Logging much else clutters up the screen. |
| 73 | +#kern.* action(type="omfile" file="/dev/console") |
| 74 | +
|
| 75 | +# Log anything (except mail) of level info or higher. |
| 76 | +# Don't log private authentication messages! |
| 77 | +*.info;mail.none;authpriv.none;cron.none action(type="omfile" file="/var/log/messages") |
| 78 | +# Log all the mail messages in one place. |
| 79 | +mail.* action(type="omfile" file="/var/log/maillog" sync="on") |
| 80 | +EOF |
0 commit comments