Skip to content

Commit 24aa962

Browse files
committed
Add new test scenarios for rsyslog_logfiles_attributes_modify template.
1 parent d9efc55 commit 24aa962

File tree

2 files changed

+152
-0
lines changed

2 files changed

+152
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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+
{{% elif ATTRIBUTE == "groupowner" %}}
11+
CHATTR="chgrp"
12+
ATTR_VALUE="root"
13+
{{% else %}}
14+
CHATTR="chmod"
15+
ATTR_VALUE="0640"
16+
{{% endif %}}
17+
18+
touch /var/log/messages
19+
20+
$CHATTR $ATTR_VALUE /var/log/messages
21+
22+
cat <<EOF >$RSYSLOG_CONF
23+
# rsyslog configuration file
24+
25+
# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
26+
# or latest version online at http://www.rsyslog.com/doc/rsyslog_conf.html
27+
# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html
28+
29+
#### GLOBAL DIRECTIVES ####
30+
31+
# Where to place auxiliary files
32+
global(workDirectory="/var/lib/rsyslog")
33+
34+
#### MODULES ####
35+
36+
# Use default timestamp format
37+
module(load="builtin:omfile" Template="RSYSLOG_TraditionalFileFormat")
38+
39+
module(load="imuxsock" # provides support for local system logging (e.g. via logger command)
40+
SysSock.Use="off") # Turn off message reception via local log socket;
41+
# local messages are retrieved through imjournal now.
42+
module(load="imjournal" # provides access to the systemd journal
43+
UsePid="system" # PID nummber is retrieved as the ID of the process the journal entry originates from
44+
FileCreateMode="0644" # Set the access permissions for the state file
45+
StateFile="imjournal.state") # File to store the position in the journal
46+
47+
# Include all config files in /etc/rsyslog.d/
48+
include(file="/etc/rsyslog.d/*.conf" mode="optional")
49+
50+
#module(load="imklog") # reads kernel messages (the same are read from journald)
51+
#module(load="immark") # provides --MARK-- message capability
52+
53+
# Provides UDP syslog reception
54+
# for parameters see http://www.rsyslog.com/doc/imudp.html
55+
#module(load="imudp") # needs to be done just once
56+
#input(type="imudp" port="514")
57+
58+
# Provides TCP syslog reception
59+
# for parameters see http://www.rsyslog.com/doc/imtcp.html
60+
#module(load="imtcp") # needs to be done just once
61+
#input(type="imtcp" port="514")
62+
63+
#### RULES ####
64+
65+
# Log all kernel messages to the console.
66+
# Logging much else clutters up the screen.
67+
#kern.* action(type="omfile" file="/dev/console")
68+
69+
# Log anything (except mail) of level info or higher.
70+
# Don't log private authentication messages!
71+
*.info;mail.none;authpriv.none;cron.none action(type="omfile" file="/var/log/messages")
72+
EOF
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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

Comments
 (0)