|
|
825e43 |
From b8d2b568eb07b10f8a51f1327e399303bc06528d Mon Sep 17 00:00:00 2001
|
|
|
825e43 |
From: Watson Sato <wsato@redhat.com>
|
|
|
825e43 |
Date: Mon, 13 Feb 2023 17:49:12 +0100
|
|
|
825e43 |
Subject: [PATCH 1/5] Rsyslog files rules remediations
|
|
|
825e43 |
|
|
|
825e43 |
Patch-name: scap-security-guide-0.1.67-rsyslog_files_rules_remediations-PR_9789.patch
|
|
|
825e43 |
Patch-status: Rsyslog files rules remediations
|
|
|
825e43 |
---
|
|
|
825e43 |
controls/cis_sle12.yml | 4 +-
|
|
|
825e43 |
controls/cis_sle15.yml | 4 +-
|
|
|
825e43 |
.../file_groupowner_logfiles_value.var | 18 ---
|
|
|
825e43 |
.../oval/shared.xml | 116 ---------------
|
|
|
825e43 |
.../rsyslog_files_groupownership/rule.yml | 39 ++++-
|
|
|
825e43 |
.../tests/IncludeConfig_is_other.fail.sh | 42 ------
|
|
|
825e43 |
.../tests/IncludeConfig_is_root.pass.sh | 39 -----
|
|
|
825e43 |
.../tests/include_is_other.fail.sh | 42 ------
|
|
|
825e43 |
.../tests/include_is_root.pass.sh | 39 -----
|
|
|
825e43 |
.../tests/include_multiline_is_root.pass.sh | 41 ------
|
|
|
825e43 |
.../tests/is_other.fail.sh | 25 ----
|
|
|
825e43 |
.../tests/is_root.pass.sh | 24 ---
|
|
|
825e43 |
.../rsyslog_files_ownership/oval/shared.xml | 114 ---------------
|
|
|
825e43 |
.../rsyslog_files_ownership/rule.yml | 44 +++++-
|
|
|
825e43 |
.../ansible/shared.yml | 12 ++
|
|
|
825e43 |
.../rsyslog_logging_configured/bash/shared.sh | 7 +
|
|
|
825e43 |
.../oval/shared.xml | 41 ++++++
|
|
|
825e43 |
.../rsyslog_logging_configured/rule.yml | 34 +++++
|
|
|
825e43 |
...with_everything_logged_to_messages.pass.sh | 13 ++
|
|
|
825e43 |
.../rsyslog_file_with_no_logging.fail.sh | 12 ++
|
|
|
825e43 |
.../profiles/anssi_np_nt28_average.profile | 2 -
|
|
|
825e43 |
products/debian10/profiles/standard.profile | 2 -
|
|
|
825e43 |
.../profiles/anssi_np_nt28_average.profile | 2 -
|
|
|
825e43 |
products/debian11/profiles/standard.profile | 2 -
|
|
|
825e43 |
products/rhel7/profiles/rht-ccp.profile | 2 -
|
|
|
825e43 |
products/rhel8/profiles/rht-ccp.profile | 2 -
|
|
|
825e43 |
.../profiles/anssi_bp28_intermediary.profile | 1 +
|
|
|
825e43 |
products/sle15/profiles/standard.profile | 2 -
|
|
|
825e43 |
.../profiles/anssi_np_nt28_average.profile | 2 -
|
|
|
825e43 |
products/ubuntu1604/profiles/standard.profile | 2 -
|
|
|
825e43 |
.../profiles/anssi_np_nt28_average.profile | 2 -
|
|
|
825e43 |
products/ubuntu1804/profiles/standard.profile | 2 -
|
|
|
825e43 |
products/ubuntu2004/profiles/standard.profile | 2 -
|
|
|
825e43 |
products/ubuntu2204/profiles/standard.profile | 2 -
|
|
|
825e43 |
shared/references/cce-sle12-avail.txt | 1 -
|
|
|
825e43 |
shared/references/cce-sle15-avail.txt | 1 -
|
|
|
825e43 |
.../ansible.template | 68 +++++++++
|
|
|
825e43 |
.../bash.template | 110 ++++++++++++++
|
|
|
825e43 |
.../oval.template | 137 ++++++++++++++++++
|
|
|
825e43 |
.../template.yml | 4 +
|
|
|
825e43 |
.../tests/IncludeConfig_is_other.fail.sh | 14 +-
|
|
|
825e43 |
.../tests/IncludeConfig_is_root.pass.sh | 10 +-
|
|
|
825e43 |
.../tests/include_is_other.fail.sh | 14 +-
|
|
|
825e43 |
...udeConfig_is_other_RainerLogClause.fail.sh | 37 ++++-
|
|
|
825e43 |
.../tests/include_is_root.pass.sh | 11 +-
|
|
|
825e43 |
...ude_is_root_IncludeConfig_is_other.fail.sh | 16 +-
|
|
|
825e43 |
...lude_is_root_IncludeConfig_is_root.pass.sh | 12 +-
|
|
|
825e43 |
...ludeConfig_is_root_RainerLogClause.pass.sh | 22 +--
|
|
|
825e43 |
.../tests/include_multiline_is_root.pass.sh | 10 +-
|
|
|
825e43 |
.../tests/is_other.fail.sh | 12 +-
|
|
|
825e43 |
.../tests/is_root.pass.sh | 8 +-
|
|
|
825e43 |
51 files changed, 648 insertions(+), 576 deletions(-)
|
|
|
825e43 |
delete mode 100644 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/file_groupowner_logfiles_value.var
|
|
|
825e43 |
delete mode 100644 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/oval/shared.xml
|
|
|
825e43 |
delete mode 100755 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/IncludeConfig_is_other.fail.sh
|
|
|
825e43 |
delete mode 100755 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/IncludeConfig_is_root.pass.sh
|
|
|
825e43 |
delete mode 100755 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_other.fail.sh
|
|
|
825e43 |
delete mode 100755 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_root.pass.sh
|
|
|
825e43 |
delete mode 100755 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_multiline_is_root.pass.sh
|
|
|
825e43 |
delete mode 100755 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/is_other.fail.sh
|
|
|
825e43 |
delete mode 100755 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/is_root.pass.sh
|
|
|
825e43 |
delete mode 100644 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/oval/shared.xml
|
|
|
825e43 |
create mode 100644 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/ansible/shared.yml
|
|
|
825e43 |
create mode 100644 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/bash/shared.sh
|
|
|
825e43 |
create mode 100644 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/oval/shared.xml
|
|
|
825e43 |
create mode 100644 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/rule.yml
|
|
|
825e43 |
create mode 100644 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/tests/rsyslog_file_with_everything_logged_to_messages.pass.sh
|
|
|
825e43 |
create mode 100644 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/tests/rsyslog_file_with_no_logging.fail.sh
|
|
|
825e43 |
create mode 100644 shared/templates/rsyslog_logfiles_attributes_modify/ansible.template
|
|
|
825e43 |
create mode 100644 shared/templates/rsyslog_logfiles_attributes_modify/bash.template
|
|
|
825e43 |
create mode 100644 shared/templates/rsyslog_logfiles_attributes_modify/oval.template
|
|
|
825e43 |
create mode 100644 shared/templates/rsyslog_logfiles_attributes_modify/template.yml
|
|
|
825e43 |
rename {linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership => shared/templates/rsyslog_logfiles_attributes_modify}/tests/IncludeConfig_is_other.fail.sh (75%)
|
|
|
825e43 |
rename {linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership => shared/templates/rsyslog_logfiles_attributes_modify}/tests/IncludeConfig_is_root.pass.sh (81%)
|
|
|
825e43 |
rename {linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership => shared/templates/rsyslog_logfiles_attributes_modify}/tests/include_is_other.fail.sh (75%)
|
|
|
825e43 |
rename linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_root_IncludeConfig_is_root.pass.sh => shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_other_IncludeConfig_is_other_RainerLogClause.fail.sh (50%)
|
|
|
825e43 |
mode change 100755 => 100644
|
|
|
825e43 |
rename {linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership => shared/templates/rsyslog_logfiles_attributes_modify}/tests/include_is_root.pass.sh (81%)
|
|
|
825e43 |
rename {linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership => shared/templates/rsyslog_logfiles_attributes_modify}/tests/include_is_root_IncludeConfig_is_other.fail.sh (77%)
|
|
|
825e43 |
rename {linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership => shared/templates/rsyslog_logfiles_attributes_modify}/tests/include_is_root_IncludeConfig_is_root.pass.sh (82%)
|
|
|
825e43 |
rename linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_root_IncludeConfig_is_other.fail.sh => shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_root_IncludeConfig_is_root_RainerLogClause.pass.sh (65%)
|
|
|
825e43 |
rename {linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership => shared/templates/rsyslog_logfiles_attributes_modify}/tests/include_multiline_is_root.pass.sh (81%)
|
|
|
825e43 |
rename {linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership => shared/templates/rsyslog_logfiles_attributes_modify}/tests/is_other.fail.sh (70%)
|
|
|
825e43 |
rename {linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership => shared/templates/rsyslog_logfiles_attributes_modify}/tests/is_root.pass.sh (77%)
|
|
|
825e43 |
|
|
|
825e43 |
diff --git a/controls/cis_sle12.yml b/controls/cis_sle12.yml
|
|
|
825e43 |
index 5c464fe556..8576343b9d 100644
|
|
|
825e43 |
--- a/controls/cis_sle12.yml
|
|
|
825e43 |
+++ b/controls/cis_sle12.yml
|
|
|
825e43 |
@@ -1321,7 +1321,9 @@ controls:
|
|
|
825e43 |
levels:
|
|
|
825e43 |
- l1_server
|
|
|
825e43 |
- l1_workstation
|
|
|
825e43 |
- status: manual
|
|
|
825e43 |
+ automated: yes
|
|
|
825e43 |
+ rules:
|
|
|
825e43 |
+ - rsyslog_logging_configured
|
|
|
825e43 |
|
|
|
825e43 |
- id: 4.2.1.5
|
|
|
825e43 |
title: Ensure rsyslog is configured to send logs to a remote log host (Automated)
|
|
|
825e43 |
diff --git a/controls/cis_sle15.yml b/controls/cis_sle15.yml
|
|
|
825e43 |
index 36d7616f90..f82341a038 100644
|
|
|
825e43 |
--- a/controls/cis_sle15.yml
|
|
|
825e43 |
+++ b/controls/cis_sle15.yml
|
|
|
825e43 |
@@ -1469,7 +1469,9 @@ controls:
|
|
|
825e43 |
levels:
|
|
|
825e43 |
- l1_server
|
|
|
825e43 |
- l1_workstation
|
|
|
825e43 |
- status: manual
|
|
|
825e43 |
+ automated: yes
|
|
|
825e43 |
+ rules:
|
|
|
825e43 |
+ - rsyslog_logging_configured
|
|
|
825e43 |
|
|
|
825e43 |
- id: 4.2.1.5
|
|
|
825e43 |
title: Ensure rsyslog is configured to send logs to a remote log host (Automated)
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/file_groupowner_logfiles_value.var b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/file_groupowner_logfiles_value.var
|
|
|
825e43 |
deleted file mode 100644
|
|
|
825e43 |
index 7ebf8c191a..0000000000
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/file_groupowner_logfiles_value.var
|
|
|
825e43 |
+++ /dev/null
|
|
|
825e43 |
@@ -1,18 +0,0 @@
|
|
|
825e43 |
-documentation_complete: true
|
|
|
825e43 |
-
|
|
|
825e43 |
-title: 'group who owns log files'
|
|
|
825e43 |
-
|
|
|
825e43 |
-description: |-
|
|
|
825e43 |
- Specify group owner of all logfiles specified in
|
|
|
825e43 |
- <tt>/etc/rsyslog.conf.</tt>
|
|
|
825e43 |
-
|
|
|
825e43 |
-type: string
|
|
|
825e43 |
-
|
|
|
825e43 |
-operator: equals
|
|
|
825e43 |
-
|
|
|
825e43 |
-interactive: false
|
|
|
825e43 |
-
|
|
|
825e43 |
-options:
|
|
|
825e43 |
- default: root
|
|
|
825e43 |
- adm: adm
|
|
|
825e43 |
- root: root
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/oval/shared.xml b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/oval/shared.xml
|
|
|
825e43 |
deleted file mode 100644
|
|
|
825e43 |
index 4567f4d411..0000000000
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/oval/shared.xml
|
|
|
825e43 |
+++ /dev/null
|
|
|
825e43 |
@@ -1,116 +0,0 @@
|
|
|
825e43 |
-<def-group oval_version="5.11">
|
|
|
825e43 |
- <definition class="compliance" id="rsyslog_files_groupownership" version="1">
|
|
|
825e43 |
- {{{ oval_metadata("All syslog log files should be owned by the appropriate group.") }}}
|
|
|
825e43 |
-
|
|
|
825e43 |
- <criteria operator="AND">
|
|
|
825e43 |
- {{% if product in ["debian10", "debian11", "ubuntu1604"] %}}
|
|
|
825e43 |
- <extend_definition comment="rsyslog daemon is used as local logging daemon" definition_ref="package_rsyslog_installed" />
|
|
|
825e43 |
- {{% endif %}}
|
|
|
825e43 |
- <criterion comment="Check if all system log files are owned by the appropriate group" test_ref="test_rsyslog_files_groupownership" />
|
|
|
825e43 |
- </criteria>
|
|
|
825e43 |
-
|
|
|
825e43 |
- </definition>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- <ind:textfilecontent54_object id="object_rfg_rsyslog_include_config_value" comment="rsyslog's $IncludeConfig directive and include() object values" version="1">
|
|
|
825e43 |
- <ind:filepath>/etc/rsyslog.conf</ind:filepath>
|
|
|
825e43 |
- <ind:pattern operation="pattern match">^(?:include\([\n\s]*file="([^\s;]+)".*|\$IncludeConfig[\s]+([^\s;]+))$</ind:pattern>
|
|
|
825e43 |
- <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
|
|
|
825e43 |
- </ind:textfilecontent54_object>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- <local_variable id="var_rfg_include_config_regex" datatype="string" version="1" comment="$IncludeConfig value converted to regex">
|
|
|
825e43 |
- <unique>
|
|
|
825e43 |
- <glob_to_regex>
|
|
|
825e43 |
- <object_component item_field="subexpression" object_ref="object_rfg_rsyslog_include_config_value" />
|
|
|
825e43 |
- </glob_to_regex>
|
|
|
825e43 |
- </unique>
|
|
|
825e43 |
- </local_variable>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- If the variable has no values, there won't be any objects -->
|
|
|
825e43 |
- <ind:variable_object id="object_var_rfg_include_config_regex" comment="Make variable object from regex variable" version="1">
|
|
|
825e43 |
- <ind:var_ref>var_rfg_include_config_regex</ind:var_ref>
|
|
|
825e43 |
- </ind:variable_object>
|
|
|
825e43 |
-
|
|
|
825e43 |
- <local_variable id="var_rfg_syslog_config" datatype="string" version="1" comment="Locations of all rsyslog configuration files as collection">
|
|
|
825e43 |
- <literal_component datatype="string">^/etc/rsyslog.conf$</literal_component>
|
|
|
825e43 |
- </local_variable>
|
|
|
825e43 |
-
|
|
|
825e43 |
- <ind:variable_object id="object_var_rfg_syslog_config" comment="Make variable object for use" version="1">
|
|
|
825e43 |
- <ind:var_ref>var_rfg_syslog_config</ind:var_ref>
|
|
|
825e43 |
- </ind:variable_object>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- We do it this way to avoid referencing an empty variable in a state comparison, which
|
|
|
825e43 |
- will cause a test to evaluate to fail. Combining an empty set of objects is fine though -->
|
|
|
825e43 |
- <ind:variable_object id="object_var_rfg_all_log_files" comment="Filter out empty string" version="1">
|
|
|
825e43 |
- <set>
|
|
|
825e43 |
- <object_reference>object_var_rfg_include_config_regex</object_reference>
|
|
|
825e43 |
- <object_reference>object_var_rfg_syslog_config</object_reference>
|
|
|
825e43 |
- </set>
|
|
|
825e43 |
- </ind:variable_object>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- a list of objects won't do. So we make a local_variable from the variable_objects. -->
|
|
|
825e43 |
- <local_variable id="var_rfg_all_log_files" datatype="string" version="1" comment="Locations of all rsyslog configuration files as collection">
|
|
|
825e43 |
- <object_component object_ref="object_var_rfg_all_log_files" item_field="value"/>
|
|
|
825e43 |
- </local_variable>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- that rsyslog's configuration file to select file paths for log files directives
|
|
|
825e43 |
- -->
|
|
|
825e43 |
- <ind:textfilecontent54_object id="object_rfg_log_files_paths" comment="All rsyslog configuration files" version="1">
|
|
|
825e43 |
- <ind:filepath operation="pattern match" var_ref="var_rfg_all_log_files" var_check="at least one" />
|
|
|
825e43 |
-
|
|
|
825e43 |
- to constitute a log file path if all of the following conditions are met:
|
|
|
825e43 |
- * the string represents a regular file on particular file system
|
|
|
825e43 |
- (verified via corresponding file_state below),
|
|
|
825e43 |
- * the chunk of text is in the last column in the row,
|
|
|
825e43 |
- (possibly suffixed by ';' character and rsyslog Template name),
|
|
|
825e43 |
- * contains at least one slash '/' character, and simultaneously
|
|
|
825e43 |
- doesn't contain any of ';', ':' and space characters,
|
|
|
825e43 |
- * the chunk was retrieved from a row not starting with space, '#',
|
|
|
825e43 |
- or '$' characters
|
|
|
825e43 |
- -->
|
|
|
825e43 |
- <ind:pattern operation="pattern match">^[^(\s|#|\$)]+[\s]+.*[\s]+-?(/+[^:;\s]+);*\.*$</ind:pattern>
|
|
|
825e43 |
- <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
|
|
|
825e43 |
- <filter action="exclude">state_groupownership_ignore_include_paths</filter>
|
|
|
825e43 |
- </ind:textfilecontent54_object>
|
|
|
825e43 |
-
|
|
|
825e43 |
- <ind:textfilecontent54_state id="state_groupownership_ignore_include_paths" comment="ignore" version="1">
|
|
|
825e43 |
-
|
|
|
825e43 |
- include() or $IncludeConfig statements.
|
|
|
825e43 |
- These paths are conf files, not log files. Their groupownership don't need to be as
|
|
|
825e43 |
- required for log files, thus, lets exclude them from the list of objects found
|
|
|
825e43 |
- -->
|
|
|
825e43 |
- <ind:text operation="pattern match">(?:file="[^\s;]+"|\$IncludeConfig[\s]+[^\s;]+|\/dev\/.*)</ind:text>
|
|
|
825e43 |
- </ind:textfilecontent54_state>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- retrieved from the different rsyslog configuration files
|
|
|
825e43 |
- -->
|
|
|
825e43 |
- <local_variable id="var_rfg_log_files_paths" datatype="string" version="1" comment="File paths of all rsyslog configuration files">
|
|
|
825e43 |
- <object_component item_field="subexpression" object_ref="object_rfg_log_files_paths" />
|
|
|
825e43 |
- </local_variable>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- <unix:file_test check="all" check_existence="all_exist" id="test_rsyslog_files_groupownership" version="1" comment="System log files are owned by the appropriate group">
|
|
|
825e43 |
- <unix:object object_ref="object_rsyslog_files_groupownership" />
|
|
|
825e43 |
- <unix:state state_ref="state_rsyslog_files_groupownership" />
|
|
|
825e43 |
- </unix:file_test>
|
|
|
825e43 |
-
|
|
|
825e43 |
- <unix:file_object id="object_rsyslog_files_groupownership" comment="Various system log files" version="1">
|
|
|
825e43 |
- <unix:filepath datatype="string" var_ref="var_rfg_log_files_paths" var_check="at least one" />
|
|
|
825e43 |
- </unix:file_object>
|
|
|
825e43 |
-
|
|
|
825e43 |
- <unix:file_state id="state_rsyslog_files_groupownership" version="1">
|
|
|
825e43 |
- <unix:type operation="equals">regular</unix:type>
|
|
|
825e43 |
- {{% if product in ["debian10", "debian11", "ubuntu1604", "ubuntu2004", "ubuntu2204"] %}}
|
|
|
825e43 |
- <unix:group_id datatype="int">4</unix:group_id>
|
|
|
825e43 |
- {{% else %}}
|
|
|
825e43 |
- <unix:group_id datatype="int">0</unix:group_id>
|
|
|
825e43 |
- {{% endif %}}
|
|
|
825e43 |
- </unix:file_state>
|
|
|
825e43 |
-
|
|
|
825e43 |
-</def-group>
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/rule.yml b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/rule.yml
|
|
|
825e43 |
index 4f797f4a21..13c89d90c5 100644
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/rule.yml
|
|
|
825e43 |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/rule.yml
|
|
|
825e43 |
@@ -4,15 +4,30 @@ title: 'Ensure Log Files Are Owned By Appropriate Group'
|
|
|
825e43 |
|
|
|
825e43 |
description: |-
|
|
|
825e43 |
The group-owner of all log files written by
|
|
|
825e43 |
- <tt>rsyslog</tt> should be <tt>{{{ xccdf_value("file_groupowner_logfiles_value") }}}</tt>.
|
|
|
825e43 |
+ <tt>rsyslog</tt> should be
|
|
|
825e43 |
+{{% if 'debian' in product or 'ubuntu' in product %}}
|
|
|
825e43 |
+ <tt>adm</tt>.
|
|
|
825e43 |
+{{% else %}}
|
|
|
825e43 |
+ <tt>root</tt>.
|
|
|
825e43 |
+{{% endif %}}
|
|
|
825e43 |
These log files are determined by the second part of each Rule line in
|
|
|
825e43 |
<tt>/etc/rsyslog.conf</tt> and typically all appear in <tt>/var/log</tt>.
|
|
|
825e43 |
For each log file LOGFILE referenced in <tt>/etc/rsyslog.conf</tt>,
|
|
|
825e43 |
run the following command to inspect the file's group owner:
|
|
|
825e43 |
$ ls -l LOGFILE
|
|
|
825e43 |
- If the owner is not <tt>{{{ xccdf_value("file_groupowner_logfiles_value") }}}</tt>, run the following command to
|
|
|
825e43 |
+ If the owner is not
|
|
|
825e43 |
+ {{% if 'debian' in product or 'ubuntu' in product %}}
|
|
|
825e43 |
+ <tt>adm</tt>,
|
|
|
825e43 |
+ {{% else %}}
|
|
|
825e43 |
+ <tt>root</tt>,
|
|
|
825e43 |
+ {{% endif %}}
|
|
|
825e43 |
+ run the following command to
|
|
|
825e43 |
correct this:
|
|
|
825e43 |
- $ sudo chgrp {{{ xccdf_value("file_groupowner_logfiles_value") }}} LOGFILE
|
|
|
825e43 |
+{{% if 'debian' in product or 'ubuntu' in product %}}
|
|
|
825e43 |
+ $ sudo chgrp adm LOGFILE
|
|
|
825e43 |
+{{% else %}}
|
|
|
825e43 |
+ $ sudo chgrp root LOGFILE
|
|
|
825e43 |
+{{% endif %}}
|
|
|
825e43 |
|
|
|
825e43 |
rationale: |-
|
|
|
825e43 |
The log files generated by rsyslog contain valuable information regarding system
|
|
|
825e43 |
@@ -47,8 +62,24 @@ references:
|
|
|
825e43 |
ocil_clause: 'the group-owner is not correct'
|
|
|
825e43 |
|
|
|
825e43 |
ocil: |-
|
|
|
825e43 |
- The group-owner of all log files written by <tt>rsyslog</tt> should be <tt>{{{ xccdf_value("file_groupowner_logfiles_value") }}}</tt>.
|
|
|
825e43 |
+ The group-owner of all log files written by <tt>rsyslog</tt> should be
|
|
|
825e43 |
+ {{% if 'debian' in product or 'ubuntu' in product %}}
|
|
|
825e43 |
+ <tt>adm</tt>.
|
|
|
825e43 |
+ {{% else %}}
|
|
|
825e43 |
+ <tt>root</tt>.
|
|
|
825e43 |
+ {{% endif %}}
|
|
|
825e43 |
These log files are determined by the second part of each Rule line in
|
|
|
825e43 |
<tt>/etc/rsyslog.conf</tt> and typically all appear in <tt>/var/log</tt>.
|
|
|
825e43 |
To see the group-owner of a given log file, run the following command:
|
|
|
825e43 |
$ ls -l LOGFILE
|
|
|
825e43 |
+
|
|
|
825e43 |
+template:
|
|
|
825e43 |
+ name: rsyslog_logfiles_attributes_modify
|
|
|
825e43 |
+ vars:
|
|
|
825e43 |
+ attribute: groupowner
|
|
|
825e43 |
+ value: 0
|
|
|
825e43 |
+ value@debian10: 4
|
|
|
825e43 |
+ value@debian11: 4
|
|
|
825e43 |
+ value@ubuntu1604: 4
|
|
|
825e43 |
+ value@ubuntu2004: 4
|
|
|
825e43 |
+ value@ubuntu2204: 4
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/IncludeConfig_is_other.fail.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/IncludeConfig_is_other.fail.sh
|
|
|
825e43 |
deleted file mode 100755
|
|
|
825e43 |
index 575530ef2e..0000000000
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/IncludeConfig_is_other.fail.sh
|
|
|
825e43 |
+++ /dev/null
|
|
|
825e43 |
@@ -1,42 +0,0 @@
|
|
|
825e43 |
-#!/bin/bash
|
|
|
825e43 |
-# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_sle
|
|
|
825e43 |
-
|
|
|
825e43 |
-# Check rsyslog.conf with root group-owner log from rules and
|
|
|
825e43 |
-# non root group-owner log from $IncludeConfig fails.
|
|
|
825e43 |
-
|
|
|
825e43 |
-source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
-
|
|
|
825e43 |
-GROUP_TEST=testssg
|
|
|
825e43 |
-groupadd $GROUP_TEST
|
|
|
825e43 |
-
|
|
|
825e43 |
-GROUP_ROOT=root
|
|
|
825e43 |
-
|
|
|
825e43 |
-# setup test data
|
|
|
825e43 |
-create_rsyslog_test_logs 2
|
|
|
825e43 |
-
|
|
|
825e43 |
-# setup test log files ownership
|
|
|
825e43 |
-chgrp $GROUP_ROOT ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-chgrp $GROUP_TEST ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
-
|
|
|
825e43 |
-# create test configuration file
|
|
|
825e43 |
-test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
825e43 |
-cat << EOF > ${test_conf}
|
|
|
825e43 |
-# rsyslog configuration file
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### RULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-*.* ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
-EOF
|
|
|
825e43 |
-
|
|
|
825e43 |
-# create rsyslog.conf configuration file
|
|
|
825e43 |
-cat << EOF > $RSYSLOG_CONF
|
|
|
825e43 |
-# rsyslog configuration file
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### RULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-*.* ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### MODULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-\$IncludeConfig ${test_conf}
|
|
|
825e43 |
-EOF
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/IncludeConfig_is_root.pass.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/IncludeConfig_is_root.pass.sh
|
|
|
825e43 |
deleted file mode 100755
|
|
|
825e43 |
index 39efc1a4b7..0000000000
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/IncludeConfig_is_root.pass.sh
|
|
|
825e43 |
+++ /dev/null
|
|
|
825e43 |
@@ -1,39 +0,0 @@
|
|
|
825e43 |
-#!/bin/bash
|
|
|
825e43 |
-# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_sle
|
|
|
825e43 |
-
|
|
|
825e43 |
-# Check rsyslog.conf with root group-owner log from rules and
|
|
|
825e43 |
-# root group-owner log from $IncludeConfig passes.
|
|
|
825e43 |
-
|
|
|
825e43 |
-source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
-
|
|
|
825e43 |
-GROUP=root
|
|
|
825e43 |
-
|
|
|
825e43 |
-# setup test data
|
|
|
825e43 |
-create_rsyslog_test_logs 2
|
|
|
825e43 |
-
|
|
|
825e43 |
-# setup test log files ownership
|
|
|
825e43 |
-chgrp $GROUP ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-chgrp $GROUP ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
-
|
|
|
825e43 |
-# create test configuration file
|
|
|
825e43 |
-test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
825e43 |
-cat << EOF > ${test_conf}
|
|
|
825e43 |
-# rsyslog configuration file
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### RULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-*.* ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
-EOF
|
|
|
825e43 |
-
|
|
|
825e43 |
-# create rsyslog.conf configuration file
|
|
|
825e43 |
-cat << EOF > $RSYSLOG_CONF
|
|
|
825e43 |
-# rsyslog configuration file
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### RULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-*.* ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### MODULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-\$IncludeConfig ${test_conf}
|
|
|
825e43 |
-EOF
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_other.fail.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_other.fail.sh
|
|
|
825e43 |
deleted file mode 100755
|
|
|
825e43 |
index c0db7056b4..0000000000
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_other.fail.sh
|
|
|
825e43 |
+++ /dev/null
|
|
|
825e43 |
@@ -1,42 +0,0 @@
|
|
|
825e43 |
-#!/bin/bash
|
|
|
825e43 |
-# platform = Red Hat Enterprise Linux 8,multi_platform_fedora,Oracle Linux 8,multi_platform_sle
|
|
|
825e43 |
-
|
|
|
825e43 |
-# Check rsyslog.conf with root group-owner log from rules and
|
|
|
825e43 |
-# non root group-owner log from include() fails.
|
|
|
825e43 |
-
|
|
|
825e43 |
-source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
-
|
|
|
825e43 |
-GROUP_TEST=testssg
|
|
|
825e43 |
-groupadd $GROUP_TEST
|
|
|
825e43 |
-
|
|
|
825e43 |
-GROUP_ROOT=root
|
|
|
825e43 |
-
|
|
|
825e43 |
-# setup test data
|
|
|
825e43 |
-create_rsyslog_test_logs 2
|
|
|
825e43 |
-
|
|
|
825e43 |
-# setup test log files ownership
|
|
|
825e43 |
-chgrp $GROUP_ROOT ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-chgrp $GROUP_TEST ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
-
|
|
|
825e43 |
-# create test configuration file
|
|
|
825e43 |
-test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
825e43 |
-cat << EOF > ${test_conf}
|
|
|
825e43 |
-# rsyslog configuration file
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### RULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-*.* ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
-EOF
|
|
|
825e43 |
-
|
|
|
825e43 |
-# create rsyslog.conf configuration file
|
|
|
825e43 |
-cat << EOF > $RSYSLOG_CONF
|
|
|
825e43 |
-# rsyslog configuration file
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### RULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-*.* ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### MODULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-include(file="${test_conf}")
|
|
|
825e43 |
-EOF
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_root.pass.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_root.pass.sh
|
|
|
825e43 |
deleted file mode 100755
|
|
|
825e43 |
index 1feaf762fc..0000000000
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_root.pass.sh
|
|
|
825e43 |
+++ /dev/null
|
|
|
825e43 |
@@ -1,39 +0,0 @@
|
|
|
825e43 |
-#!/bin/bash
|
|
|
825e43 |
-# platform = Red Hat Enterprise Linux 8,multi_platform_fedora,Oracle Linux 8,multi_platform_sle
|
|
|
825e43 |
-
|
|
|
825e43 |
-# Check rsyslog.conf with root group-owner log from rules and
|
|
|
825e43 |
-# root group-owner log from include() passes.
|
|
|
825e43 |
-
|
|
|
825e43 |
-source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
-
|
|
|
825e43 |
-GROUP=root
|
|
|
825e43 |
-
|
|
|
825e43 |
-# setup test data
|
|
|
825e43 |
-create_rsyslog_test_logs 2
|
|
|
825e43 |
-
|
|
|
825e43 |
-# setup test log files ownership
|
|
|
825e43 |
-chgrp $GROUP ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-chgrp $GROUP ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
-
|
|
|
825e43 |
-# create test configuration file
|
|
|
825e43 |
-test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
825e43 |
-cat << EOF > ${test_conf}
|
|
|
825e43 |
-# rsyslog configuration file
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### RULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-*.* ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
-EOF
|
|
|
825e43 |
-
|
|
|
825e43 |
-# create rsyslog.conf configuration file
|
|
|
825e43 |
-cat << EOF > $RSYSLOG_CONF
|
|
|
825e43 |
-# rsyslog configuration file
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### RULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-*.* ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### MODULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-include(file="${test_conf}")
|
|
|
825e43 |
-EOF
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_multiline_is_root.pass.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_multiline_is_root.pass.sh
|
|
|
825e43 |
deleted file mode 100755
|
|
|
825e43 |
index 5a357d029b..0000000000
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_multiline_is_root.pass.sh
|
|
|
825e43 |
+++ /dev/null
|
|
|
825e43 |
@@ -1,41 +0,0 @@
|
|
|
825e43 |
-#!/bin/bash
|
|
|
825e43 |
-# platform = Red Hat Enterprise Linux 8,multi_platform_fedora,Oracle Linux 8,multi_platform_sle
|
|
|
825e43 |
-
|
|
|
825e43 |
-# Check rsyslog.conf with root group-owner log from rules and
|
|
|
825e43 |
-# root group-owner log from multiline include() passes.
|
|
|
825e43 |
-
|
|
|
825e43 |
-source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
-
|
|
|
825e43 |
-GROUP=root
|
|
|
825e43 |
-
|
|
|
825e43 |
-# setup test data
|
|
|
825e43 |
-create_rsyslog_test_logs 2
|
|
|
825e43 |
-
|
|
|
825e43 |
-# setup test log files ownership
|
|
|
825e43 |
-chgrp $GROUP ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-chgrp $GROUP ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
-
|
|
|
825e43 |
-# create test configuration file
|
|
|
825e43 |
-test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
825e43 |
-cat << EOF > ${test_conf}
|
|
|
825e43 |
-# rsyslog configuration file
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### RULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-*.* ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
-EOF
|
|
|
825e43 |
-
|
|
|
825e43 |
-# create rsyslog.conf configuration file
|
|
|
825e43 |
-cat << EOF > $RSYSLOG_CONF
|
|
|
825e43 |
-# rsyslog configuration file
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### RULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-*.* ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### MODULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-include(
|
|
|
825e43 |
- file="${test_conf}"
|
|
|
825e43 |
-)
|
|
|
825e43 |
-EOF
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/is_other.fail.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/is_other.fail.sh
|
|
|
825e43 |
deleted file mode 100755
|
|
|
825e43 |
index c7c01132f2..0000000000
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/is_other.fail.sh
|
|
|
825e43 |
+++ /dev/null
|
|
|
825e43 |
@@ -1,25 +0,0 @@
|
|
|
825e43 |
-#!/bin/bash
|
|
|
825e43 |
-# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_sle
|
|
|
825e43 |
-
|
|
|
825e43 |
-# Check if log file with non root group-owner in rsyslog.conf fails.
|
|
|
825e43 |
-
|
|
|
825e43 |
-source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
-
|
|
|
825e43 |
-GROUP=testssg
|
|
|
825e43 |
-
|
|
|
825e43 |
-groupadd $GROUP
|
|
|
825e43 |
-
|
|
|
825e43 |
-# setup test data
|
|
|
825e43 |
-create_rsyslog_test_logs 1
|
|
|
825e43 |
-
|
|
|
825e43 |
-# setup test log file ownership
|
|
|
825e43 |
-chgrp $GROUP ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-
|
|
|
825e43 |
-# add rule with non-root group owned log file
|
|
|
825e43 |
-cat << EOF > $RSYSLOG_CONF
|
|
|
825e43 |
-# rsyslog configuration file
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### RULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-*.* ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-EOF
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/is_root.pass.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/is_root.pass.sh
|
|
|
825e43 |
deleted file mode 100755
|
|
|
825e43 |
index 0ecbb35bd1..0000000000
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/is_root.pass.sh
|
|
|
825e43 |
+++ /dev/null
|
|
|
825e43 |
@@ -1,24 +0,0 @@
|
|
|
825e43 |
-#!/bin/bash
|
|
|
825e43 |
-# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_sle
|
|
|
825e43 |
-
|
|
|
825e43 |
-# Check if log file with root group-owner in rsyslog.conf passes.
|
|
|
825e43 |
-
|
|
|
825e43 |
-source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
-
|
|
|
825e43 |
-GROUP=root
|
|
|
825e43 |
-
|
|
|
825e43 |
-# setup test data
|
|
|
825e43 |
-create_rsyslog_test_logs 1
|
|
|
825e43 |
-
|
|
|
825e43 |
-# setup test log file ownership
|
|
|
825e43 |
-chgrp $GROUP ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-
|
|
|
825e43 |
-# add rule with root group owned log file
|
|
|
825e43 |
-cat << EOF > $RSYSLOG_CONF
|
|
|
825e43 |
-# rsyslog configuration file
|
|
|
825e43 |
-
|
|
|
825e43 |
-#### RULES ####
|
|
|
825e43 |
-
|
|
|
825e43 |
-*.* ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-
|
|
|
825e43 |
-EOF
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/oval/shared.xml b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/oval/shared.xml
|
|
|
825e43 |
deleted file mode 100644
|
|
|
825e43 |
index 8e3f68db26..0000000000
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/oval/shared.xml
|
|
|
825e43 |
+++ /dev/null
|
|
|
825e43 |
@@ -1,114 +0,0 @@
|
|
|
825e43 |
-<def-group oval_version="5.11">
|
|
|
825e43 |
- <definition class="compliance" id="rsyslog_files_ownership" version="1">
|
|
|
825e43 |
- {{{ oval_metadata("All syslog log files should be owned by the appropriate user.") }}}
|
|
|
825e43 |
-
|
|
|
825e43 |
- <criteria>
|
|
|
825e43 |
- <criterion comment="Check if all system log files are owned by appropriate user" test_ref="test_rsyslog_files_ownership" />
|
|
|
825e43 |
- </criteria>
|
|
|
825e43 |
-
|
|
|
825e43 |
- </definition>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- <ind:textfilecontent54_object id="object_rfo_rsyslog_include_config_value" comment="rsyslog's $IncludeConfig directive and include() object values" version="1">
|
|
|
825e43 |
- <ind:filepath>/etc/rsyslog.conf</ind:filepath>
|
|
|
825e43 |
- <ind:pattern operation="pattern match">^(?:include\([\n\s]*file="([^\s;]+)".*|\$IncludeConfig[\s]+([^\s;]+))$</ind:pattern>
|
|
|
825e43 |
- <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
|
|
|
825e43 |
- </ind:textfilecontent54_object>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- <local_variable id="var_rfo_include_config_regex" datatype="string" version="1" comment="$IncludeConfig value converted to regex">
|
|
|
825e43 |
- <unique>
|
|
|
825e43 |
- <glob_to_regex>
|
|
|
825e43 |
- <object_component item_field="subexpression" object_ref="object_rfo_rsyslog_include_config_value" />
|
|
|
825e43 |
- </glob_to_regex>
|
|
|
825e43 |
- </unique>
|
|
|
825e43 |
- </local_variable>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- If the variable has no values, there won't be any objects -->
|
|
|
825e43 |
- <ind:variable_object id="object_var_rfo_include_config_regex" comment="Make variable object from regex variable" version="1">
|
|
|
825e43 |
- <ind:var_ref>var_rfo_include_config_regex</ind:var_ref>
|
|
|
825e43 |
- </ind:variable_object>
|
|
|
825e43 |
-
|
|
|
825e43 |
- <local_variable id="var_rfo_syslog_config" datatype="string" version="1" comment="Locations of all rsyslog configuration files as collection">
|
|
|
825e43 |
- <literal_component datatype="string">^/etc/rsyslog.conf$</literal_component>
|
|
|
825e43 |
- </local_variable>
|
|
|
825e43 |
-
|
|
|
825e43 |
- <ind:variable_object id="object_var_rfo_syslog_config" comment="Make variable object for use" version="1">
|
|
|
825e43 |
- <ind:var_ref>var_rfo_syslog_config</ind:var_ref>
|
|
|
825e43 |
- </ind:variable_object>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- We do it this way to avoid referencing an empty variable in a state comparison, which
|
|
|
825e43 |
- will cause a test to evaluate to fail. Combining an empty set of objects is fine though -->
|
|
|
825e43 |
- <ind:variable_object id="object_var_rfo_all_log_files" comment="Filter out empty string" version="1">
|
|
|
825e43 |
- <set>
|
|
|
825e43 |
- <object_reference>object_var_rfo_include_config_regex</object_reference>
|
|
|
825e43 |
- <object_reference>object_var_rfo_syslog_config</object_reference>
|
|
|
825e43 |
- </set>
|
|
|
825e43 |
- </ind:variable_object>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- a list of objects won't do. So we make a local_variable from the variable_objects. -->
|
|
|
825e43 |
- <local_variable id="var_rfo_all_log_files" datatype="string" version="1" comment="Locations of all rsyslog configuration files as collection">
|
|
|
825e43 |
- <object_component object_ref="object_var_rfo_all_log_files" item_field="value"/>
|
|
|
825e43 |
- </local_variable>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- that rsyslog's configuration file to select file paths for log files directives
|
|
|
825e43 |
- -->
|
|
|
825e43 |
- <ind:textfilecontent54_object id="object_rfo_log_files_paths" comment="All rsyslog configuration files" version="1">
|
|
|
825e43 |
- <ind:filepath operation="pattern match" var_ref="var_rfo_all_log_files" var_check="at least one" />
|
|
|
825e43 |
-
|
|
|
825e43 |
- to constitute a log file path if all of the following conditions are met:
|
|
|
825e43 |
- * the string represents a regular file on particular file system
|
|
|
825e43 |
- (verified via corresponding file_state below),
|
|
|
825e43 |
- * the chunk of text is in the last column in the row,
|
|
|
825e43 |
- (possibly suffixed by ';' character and rsyslog Template name),
|
|
|
825e43 |
- * contains at least one slash '/' character, and simultaneously
|
|
|
825e43 |
- doesn't contain any of ';', ':' and space characters,
|
|
|
825e43 |
- * the chunk was retrieved from a row not starting with space, '#',
|
|
|
825e43 |
- or '$' characters
|
|
|
825e43 |
- -->
|
|
|
825e43 |
- <ind:pattern operation="pattern match">^[^(#|\$)]+[\s]+.*[\s]+-?(/+[^:;\s]+);*\.*$</ind:pattern>
|
|
|
825e43 |
- <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
|
|
|
825e43 |
- <filter action="exclude">state_owner_ignore_include_paths</filter>
|
|
|
825e43 |
- </ind:textfilecontent54_object>
|
|
|
825e43 |
-
|
|
|
825e43 |
- <ind:textfilecontent54_state id="state_owner_ignore_include_paths" comment="ignore" version="1">
|
|
|
825e43 |
-
|
|
|
825e43 |
- include() or $IncludeConfig statements.
|
|
|
825e43 |
- These paths are conf files, not log files. Their owner don't need to be as
|
|
|
825e43 |
- required for log files, thus, lets exclude them from the list of objects found
|
|
|
825e43 |
- -->
|
|
|
825e43 |
- <ind:text operation="pattern match">(?:file="[^\s;]+"|\$IncludeConfig[\s]+[^\s;]+|\/dev\/.*)</ind:text>
|
|
|
825e43 |
- </ind:textfilecontent54_state>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- retrieved from the different rsyslog configuration files
|
|
|
825e43 |
- -->
|
|
|
825e43 |
- <local_variable id="var_rfo_log_files_paths" datatype="string" version="1" comment="File paths of all rsyslog configuration files">
|
|
|
825e43 |
- <object_component item_field="subexpression" object_ref="object_rfo_log_files_paths" />
|
|
|
825e43 |
- </local_variable>
|
|
|
825e43 |
-
|
|
|
825e43 |
-
|
|
|
825e43 |
- <unix:file_test check="all" check_existence="all_exist" id="test_rsyslog_files_ownership" version="1" comment="System log files are owned by the appropriate user">
|
|
|
825e43 |
- <unix:object object_ref="object_rsyslog_files_ownership" />
|
|
|
825e43 |
- <unix:state state_ref="state_rsyslog_files_ownership" />
|
|
|
825e43 |
- </unix:file_test>
|
|
|
825e43 |
-
|
|
|
825e43 |
- <unix:file_object id="object_rsyslog_files_ownership" comment="Various system log files" version="1">
|
|
|
825e43 |
- <unix:filepath datatype="string" var_ref="var_rfo_log_files_paths" var_check="at least one" />
|
|
|
825e43 |
- </unix:file_object>
|
|
|
825e43 |
-
|
|
|
825e43 |
- <unix:file_state id="state_rsyslog_files_ownership" version="1">
|
|
|
825e43 |
- <unix:type operation="equals">regular</unix:type>
|
|
|
825e43 |
-
|
|
|
825e43 |
- {{% if product in ["ubuntu2004", "ubuntu2204"] %}}
|
|
|
825e43 |
- <unix:user_id datatype="int">104</unix:user_id>
|
|
|
825e43 |
- {{% else %}}
|
|
|
825e43 |
- <unix:user_id datatype="int">0</unix:user_id>
|
|
|
825e43 |
- {{% endif %}}
|
|
|
825e43 |
- </unix:file_state>
|
|
|
825e43 |
-
|
|
|
825e43 |
-</def-group>
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/rule.yml b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/rule.yml
|
|
|
825e43 |
index 37c87b07cd..0d9bf40f4b 100644
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/rule.yml
|
|
|
825e43 |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/rule.yml
|
|
|
825e43 |
@@ -4,15 +4,36 @@ title: 'Ensure Log Files Are Owned By Appropriate User'
|
|
|
825e43 |
|
|
|
825e43 |
description: |-
|
|
|
825e43 |
The owner of all log files written by
|
|
|
825e43 |
- <tt>rsyslog</tt> should be <tt>{{{ xccdf_value("file_owner_logfiles_value") }}}</tt>.
|
|
|
825e43 |
+ <tt>rsyslog</tt> should be
|
|
|
825e43 |
+ {{% if product in ['ubuntu2204','ubuntu2004'] %}}
|
|
|
825e43 |
+ <tt>syslog</tt>.
|
|
|
825e43 |
+ {{% elif 'debian' in product or 'ubuntu' in product %}}
|
|
|
825e43 |
+ <tt>adm</tt>.
|
|
|
825e43 |
+ {{% else %}}
|
|
|
825e43 |
+ <tt>root</tt>.
|
|
|
825e43 |
+ {{% endif %}}
|
|
|
825e43 |
These log files are determined by the second part of each Rule line in
|
|
|
825e43 |
<tt>/etc/rsyslog.conf</tt> and typically all appear in <tt>/var/log</tt>.
|
|
|
825e43 |
For each log file LOGFILE referenced in <tt>/etc/rsyslog.conf</tt>,
|
|
|
825e43 |
run the following command to inspect the file's owner:
|
|
|
825e43 |
$ ls -l LOGFILE
|
|
|
825e43 |
- If the owner is not <tt>{{{ xccdf_value("file_owner_logfiles_value") }}}</tt>, run the following command to
|
|
|
825e43 |
+ If the owner is not
|
|
|
825e43 |
+ {{% if product in ['ubuntu2204','ubuntu2004'] %}}
|
|
|
825e43 |
+ <tt>syslog</tt>,
|
|
|
825e43 |
+ {{% elif 'debian' in product or 'ubuntu' in product %}}
|
|
|
825e43 |
+ <tt>adm</tt>,
|
|
|
825e43 |
+ {{% else %}}
|
|
|
825e43 |
+ <tt>root</tt>,
|
|
|
825e43 |
+ {{% endif %}}
|
|
|
825e43 |
+ run the following command to
|
|
|
825e43 |
correct this:
|
|
|
825e43 |
- $ sudo chown {{{ xccdf_value("file_owner_logfiles_value") }}} LOGFILE
|
|
|
825e43 |
+ {{% if product in ['ubuntu2204','ubuntu2004'] %}}
|
|
|
825e43 |
+ $ sudo chown syslog LOGFILE
|
|
|
825e43 |
+ {{% elif 'debian' in product or 'ubuntu' in product %}}
|
|
|
825e43 |
+ $ sudo chown adm LOGFILE
|
|
|
825e43 |
+ {{% else %}}
|
|
|
825e43 |
+ $ sudo chown root LOGFILE
|
|
|
825e43 |
+ {{% endif %}}
|
|
|
825e43 |
|
|
|
825e43 |
rationale: |-
|
|
|
825e43 |
The log files generated by rsyslog contain valuable information regarding system
|
|
|
825e43 |
@@ -47,8 +68,23 @@ references:
|
|
|
825e43 |
ocil_clause: 'the owner is not correct'
|
|
|
825e43 |
|
|
|
825e43 |
ocil: |-
|
|
|
825e43 |
- The owner of all log files written by <tt>rsyslog</tt> should be <tt>{{{ xccdf_value("file_owner_logfiles_value") }}}</tt>.
|
|
|
825e43 |
+ The owner of all log files written by <tt>rsyslog</tt> should be
|
|
|
825e43 |
+ {{% if product in ['ubuntu2204','ubuntu2004'] %}}
|
|
|
825e43 |
+ <tt>syslog</tt>.
|
|
|
825e43 |
+ {{% elif 'debian' in product or 'ubuntu' in product %}}
|
|
|
825e43 |
+ <tt>adm</tt>.
|
|
|
825e43 |
+ {{% else %}}
|
|
|
825e43 |
+ <tt>root</tt>.
|
|
|
825e43 |
+ {{% endif %}}
|
|
|
825e43 |
These log files are determined by the second part of each Rule line in
|
|
|
825e43 |
<tt>/etc/rsyslog.conf</tt> and typically all appear in <tt>/var/log</tt>.
|
|
|
825e43 |
To see the owner of a given log file, run the following command:
|
|
|
825e43 |
$ ls -l LOGFILE
|
|
|
825e43 |
+
|
|
|
825e43 |
+template:
|
|
|
825e43 |
+ name: rsyslog_logfiles_attributes_modify
|
|
|
825e43 |
+ vars:
|
|
|
825e43 |
+ attribute: owner
|
|
|
825e43 |
+ value: 0
|
|
|
825e43 |
+ value@ubuntu2004: 104
|
|
|
825e43 |
+ value@ubuntu2204: 104
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/ansible/shared.yml b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/ansible/shared.yml
|
|
|
825e43 |
new file mode 100644
|
|
|
825e43 |
index 0000000000..041e263155
|
|
|
825e43 |
--- /dev/null
|
|
|
825e43 |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/ansible/shared.yml
|
|
|
825e43 |
@@ -0,0 +1,12 @@
|
|
|
825e43 |
+# platform = multi_platform_sle
|
|
|
825e43 |
+# reboot = false
|
|
|
825e43 |
+# strategy = restrict
|
|
|
825e43 |
+# complexity = low
|
|
|
825e43 |
+# disruption = low
|
|
|
825e43 |
+
|
|
|
825e43 |
+- name: "Set rsyslog remote loghost"
|
|
|
825e43 |
+ lineinfile:
|
|
|
825e43 |
+ dest: /etc/rsyslog.conf
|
|
|
825e43 |
+ regexp: "^\\*\\.\\*"
|
|
|
825e43 |
+ line: "*.* /var/log/messages"
|
|
|
825e43 |
+ create: yes
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/bash/shared.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/bash/shared.sh
|
|
|
825e43 |
new file mode 100644
|
|
|
825e43 |
index 0000000000..d634610225
|
|
|
825e43 |
--- /dev/null
|
|
|
825e43 |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/bash/shared.sh
|
|
|
825e43 |
@@ -0,0 +1,7 @@
|
|
|
825e43 |
+# platform = multi_platform_sle
|
|
|
825e43 |
+# reboot = false
|
|
|
825e43 |
+# strategy = restrict
|
|
|
825e43 |
+# complexity = low
|
|
|
825e43 |
+# disruption = low
|
|
|
825e43 |
+
|
|
|
825e43 |
+{{{ bash_replace_or_append('/etc/rsyslog.conf', '^\*\.\*', "/var/log/messages", '%s %s') }}}
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/oval/shared.xml b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/oval/shared.xml
|
|
|
825e43 |
new file mode 100644
|
|
|
825e43 |
index 0000000000..89e1e7616e
|
|
|
825e43 |
--- /dev/null
|
|
|
825e43 |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/oval/shared.xml
|
|
|
825e43 |
@@ -0,0 +1,41 @@
|
|
|
825e43 |
+<def-group>
|
|
|
825e43 |
+ <definition class="compliance" id="rsyslog_logging_configured" version="1">
|
|
|
825e43 |
+ {{{ oval_metadata("Syslog logs should be configured") }}}
|
|
|
825e43 |
+
|
|
|
825e43 |
+ <criteria operator="AND">
|
|
|
825e43 |
+ {{% if product in ["debian10", "debian11", "ubuntu1604", "ubuntu1804"] %}}
|
|
|
825e43 |
+ <extend_definition comment="rsyslog daemon is used as local logging daemon" definition_ref="package_rsyslog_installed" />
|
|
|
825e43 |
+ {{% endif %}}
|
|
|
825e43 |
+ <criteria operator="OR">
|
|
|
825e43 |
+ <criterion comment="Logging configured within /etc/rsyslog.conf" test_ref="test_logging_configured_rsyslog_conf" />
|
|
|
825e43 |
+ <criterion comment="Remote logging set within /etc/rsyslog.d" test_ref="test_logging_configured_rsyslog_d" />
|
|
|
825e43 |
+ </criteria>
|
|
|
825e43 |
+ </criteria>
|
|
|
825e43 |
+ </definition>
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+ comment="Ensures system logging configured in main conf file"
|
|
|
825e43 |
+ id="test_logging_configured_rsyslog_conf" version="1">
|
|
|
825e43 |
+ <ind:object object_ref="object_logging_configured_rsyslog_conf" />
|
|
|
825e43 |
+ </ind:textfilecontent54_test>
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+ comment="Ensures system logging_configured in .d files"
|
|
|
825e43 |
+ id="test_logging_configured_rsyslog_d" version="1">
|
|
|
825e43 |
+ <ind:object object_ref="object_logging_configured_rsyslog_d" />
|
|
|
825e43 |
+ </ind:textfilecontent54_test>
|
|
|
825e43 |
+
|
|
|
825e43 |
+ <ind:textfilecontent54_object id="object_logging_configured_rsyslog_conf" version="1">
|
|
|
825e43 |
+ <ind:filepath>/etc/rsyslog.conf</ind:filepath>
|
|
|
825e43 |
+ <ind:pattern operation="pattern match">^[^(\s|#|\$)]+[\s]+.*[\s]+(\:\w+\:\S*|-?(\/+[^:;\s]+);*\.*)$</ind:pattern>
|
|
|
825e43 |
+ <ind:instance datatype="int">1</ind:instance>
|
|
|
825e43 |
+ </ind:textfilecontent54_object>
|
|
|
825e43 |
+
|
|
|
825e43 |
+ <ind:textfilecontent54_object id="object_logging_configured_rsyslog_d" version="1">
|
|
|
825e43 |
+ <ind:path>/etc/rsyslog.d</ind:path>
|
|
|
825e43 |
+ <ind:filename operation="pattern match">^.+\.conf$</ind:filename>
|
|
|
825e43 |
+ <ind:pattern operation="pattern match">^[^(\s|#|\$)]+[\s]+.*[\s]+(\:\w+\:\S*|-?(\/+[^:;\s]+);*\.*)$</ind:pattern>
|
|
|
825e43 |
+ <ind:instance datatype="int">1</ind:instance>
|
|
|
825e43 |
+ </ind:textfilecontent54_object>
|
|
|
825e43 |
+
|
|
|
825e43 |
+</def-group>
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/rule.yml b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/rule.yml
|
|
|
825e43 |
new file mode 100644
|
|
|
825e43 |
index 0000000000..f9477de9e9
|
|
|
825e43 |
--- /dev/null
|
|
|
825e43 |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/rule.yml
|
|
|
825e43 |
@@ -0,0 +1,34 @@
|
|
|
825e43 |
+documentation_complete: true
|
|
|
825e43 |
+
|
|
|
825e43 |
+title: 'Ensure logging is configured'
|
|
|
825e43 |
+
|
|
|
825e43 |
+description: |-
|
|
|
825e43 |
+ The <tt>/etc/rsyslog.conf</tt> and <tt>/etc/rsyslog.d/*.conf</tt> files
|
|
|
825e43 |
+ specifies rules for logging and which files are to be used to log certain
|
|
|
825e43 |
+ classes of messages.
|
|
|
825e43 |
+
|
|
|
825e43 |
+rationale: |-
|
|
|
825e43 |
+ A great deal of important security-related information is sent via
|
|
|
825e43 |
+ rsyslog (e.g., successful and failed su attempts, failed login attempts,
|
|
|
825e43 |
+ root login attempts, etc.).
|
|
|
825e43 |
+
|
|
|
825e43 |
+severity: medium
|
|
|
825e43 |
+
|
|
|
825e43 |
+identifiers:
|
|
|
825e43 |
+ cce@sle12: CCE-92379-7
|
|
|
825e43 |
+ cce@sle15: CCE-92497-7
|
|
|
825e43 |
+
|
|
|
825e43 |
+references:
|
|
|
825e43 |
+ cis@sle12: 4.2.1.4
|
|
|
825e43 |
+ cis@sle15: 4.2.1.4
|
|
|
825e43 |
+
|
|
|
825e43 |
+ocil_clause: 'no logging is configured'
|
|
|
825e43 |
+
|
|
|
825e43 |
+ocil: |-
|
|
|
825e43 |
+ Review the contents of the <tt>/etc/rsyslog.conf</tt> and <tt>/etc/rsyslog.d/*.conf</tt>
|
|
|
825e43 |
+ files to ensure appropriate logging is set. In addition, run the following command:
|
|
|
825e43 |
+ ls -l /var/log/
|
|
|
825e43 |
+ and verify that the log files are logging information
|
|
|
825e43 |
+
|
|
|
825e43 |
+fixtext: |-
|
|
|
825e43 |
+ Configure logging with selectors covering each priority
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/tests/rsyslog_file_with_everything_logged_to_messages.pass.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/tests/rsyslog_file_with_everything_logged_to_messages.pass.sh
|
|
|
825e43 |
new file mode 100644
|
|
|
825e43 |
index 0000000000..a4fb1cf07a
|
|
|
825e43 |
--- /dev/null
|
|
|
825e43 |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/tests/rsyslog_file_with_everything_logged_to_messages.pass.sh
|
|
|
825e43 |
@@ -0,0 +1,13 @@
|
|
|
825e43 |
+#!/bin/bash
|
|
|
825e43 |
+# platform = multi_platform_sle
|
|
|
825e43 |
+
|
|
|
825e43 |
+# Check rsyslog.conf with no includes and all loggging facility/priority configured to go to /var/log/messages
|
|
|
825e43 |
+
|
|
|
825e43 |
+source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
+cat << EOF > ${RSYSLOG_CONF}
|
|
|
825e43 |
+# rsyslog configuration file
|
|
|
825e43 |
+
|
|
|
825e43 |
+#### RULES ####
|
|
|
825e43 |
+
|
|
|
825e43 |
+*.* /var/log/messages
|
|
|
825e43 |
+EOF
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/tests/rsyslog_file_with_no_logging.fail.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/tests/rsyslog_file_with_no_logging.fail.sh
|
|
|
825e43 |
new file mode 100644
|
|
|
825e43 |
index 0000000000..158cf4c98d
|
|
|
825e43 |
--- /dev/null
|
|
|
825e43 |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_logging_configured/tests/rsyslog_file_with_no_logging.fail.sh
|
|
|
825e43 |
@@ -0,0 +1,12 @@
|
|
|
825e43 |
+#!/bin/bash
|
|
|
825e43 |
+# platform = multi_platform_sle
|
|
|
825e43 |
+
|
|
|
825e43 |
+# Check rsyslog.conf with no includes and no loggging facility/priority configured
|
|
|
825e43 |
+
|
|
|
825e43 |
+source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
+cat << EOF > ${RSYSLOG_CONF}
|
|
|
825e43 |
+# rsyslog configuration file
|
|
|
825e43 |
+
|
|
|
825e43 |
+#### RULES ####
|
|
|
825e43 |
+
|
|
|
825e43 |
+EOF
|
|
|
825e43 |
diff --git a/products/debian10/profiles/anssi_np_nt28_average.profile b/products/debian10/profiles/anssi_np_nt28_average.profile
|
|
|
825e43 |
index 600f1a6f71..4c42814719 100644
|
|
|
825e43 |
--- a/products/debian10/profiles/anssi_np_nt28_average.profile
|
|
|
825e43 |
+++ b/products/debian10/profiles/anssi_np_nt28_average.profile
|
|
|
825e43 |
@@ -22,9 +22,7 @@ selections:
|
|
|
825e43 |
- sshd_allow_only_protocol2
|
|
|
825e43 |
- var_sshd_set_keepalive=0
|
|
|
825e43 |
- sshd_set_keepalive_0
|
|
|
825e43 |
- - file_owner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_ownership
|
|
|
825e43 |
- - file_groupowner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_groupownership
|
|
|
825e43 |
- rsyslog_files_permissions
|
|
|
825e43 |
- "!rsyslog_remote_loghost"
|
|
|
825e43 |
diff --git a/products/debian10/profiles/standard.profile b/products/debian10/profiles/standard.profile
|
|
|
825e43 |
index 3784182fa1..446f5aca1d 100644
|
|
|
825e43 |
--- a/products/debian10/profiles/standard.profile
|
|
|
825e43 |
+++ b/products/debian10/profiles/standard.profile
|
|
|
825e43 |
@@ -33,9 +33,7 @@ selections:
|
|
|
825e43 |
- sshd_allow_only_protocol2
|
|
|
825e43 |
- var_sshd_set_keepalive=0
|
|
|
825e43 |
- sshd_set_keepalive_0
|
|
|
825e43 |
- - file_owner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_ownership
|
|
|
825e43 |
- - file_groupowner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_groupownership
|
|
|
825e43 |
- rsyslog_files_permissions
|
|
|
825e43 |
- "!rsyslog_remote_loghost"
|
|
|
825e43 |
diff --git a/products/debian11/profiles/anssi_np_nt28_average.profile b/products/debian11/profiles/anssi_np_nt28_average.profile
|
|
|
825e43 |
index 600f1a6f71..4c42814719 100644
|
|
|
825e43 |
--- a/products/debian11/profiles/anssi_np_nt28_average.profile
|
|
|
825e43 |
+++ b/products/debian11/profiles/anssi_np_nt28_average.profile
|
|
|
825e43 |
@@ -22,9 +22,7 @@ selections:
|
|
|
825e43 |
- sshd_allow_only_protocol2
|
|
|
825e43 |
- var_sshd_set_keepalive=0
|
|
|
825e43 |
- sshd_set_keepalive_0
|
|
|
825e43 |
- - file_owner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_ownership
|
|
|
825e43 |
- - file_groupowner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_groupownership
|
|
|
825e43 |
- rsyslog_files_permissions
|
|
|
825e43 |
- "!rsyslog_remote_loghost"
|
|
|
825e43 |
diff --git a/products/debian11/profiles/standard.profile b/products/debian11/profiles/standard.profile
|
|
|
825e43 |
index e1b2c718df..c21f8d592b 100644
|
|
|
825e43 |
--- a/products/debian11/profiles/standard.profile
|
|
|
825e43 |
+++ b/products/debian11/profiles/standard.profile
|
|
|
825e43 |
@@ -33,9 +33,7 @@ selections:
|
|
|
825e43 |
- sshd_allow_only_protocol2
|
|
|
825e43 |
- var_sshd_set_keepalive=0
|
|
|
825e43 |
- sshd_set_keepalive_0
|
|
|
825e43 |
- - file_owner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_ownership
|
|
|
825e43 |
- - file_groupowner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_groupownership
|
|
|
825e43 |
- rsyslog_files_permissions
|
|
|
825e43 |
- "!rsyslog_remote_loghost"
|
|
|
825e43 |
diff --git a/products/rhel7/profiles/rht-ccp.profile b/products/rhel7/profiles/rht-ccp.profile
|
|
|
825e43 |
index 12a3a25013..a246d5a094 100644
|
|
|
825e43 |
--- a/products/rhel7/profiles/rht-ccp.profile
|
|
|
825e43 |
+++ b/products/rhel7/profiles/rht-ccp.profile
|
|
|
825e43 |
@@ -11,8 +11,6 @@ description: |-
|
|
|
825e43 |
selections:
|
|
|
825e43 |
- var_selinux_state=enforcing
|
|
|
825e43 |
- var_selinux_policy_name=targeted
|
|
|
825e43 |
- - file_owner_logfiles_value=root
|
|
|
825e43 |
- - file_groupowner_logfiles_value=root
|
|
|
825e43 |
- sshd_idle_timeout_value=5_minutes
|
|
|
825e43 |
- var_accounts_minimum_age_login_defs=7
|
|
|
825e43 |
- var_accounts_passwords_pam_faillock_deny=5
|
|
|
825e43 |
diff --git a/products/rhel8/profiles/rht-ccp.profile b/products/rhel8/profiles/rht-ccp.profile
|
|
|
825e43 |
index b192461f95..6856951bff 100644
|
|
|
825e43 |
--- a/products/rhel8/profiles/rht-ccp.profile
|
|
|
825e43 |
+++ b/products/rhel8/profiles/rht-ccp.profile
|
|
|
825e43 |
@@ -11,8 +11,6 @@ description: |-
|
|
|
825e43 |
selections:
|
|
|
825e43 |
- var_selinux_state=enforcing
|
|
|
825e43 |
- var_selinux_policy_name=targeted
|
|
|
825e43 |
- - file_owner_logfiles_value=root
|
|
|
825e43 |
- - file_groupowner_logfiles_value=root
|
|
|
825e43 |
- sshd_idle_timeout_value=5_minutes
|
|
|
825e43 |
- var_logind_session_timeout=5_minutes
|
|
|
825e43 |
- var_accounts_minimum_age_login_defs=7
|
|
|
825e43 |
diff --git a/products/sle12/profiles/anssi_bp28_intermediary.profile b/products/sle12/profiles/anssi_bp28_intermediary.profile
|
|
|
825e43 |
index 24a98fd824..22498b6b6f 100644
|
|
|
825e43 |
--- a/products/sle12/profiles/anssi_bp28_intermediary.profile
|
|
|
825e43 |
+++ b/products/sle12/profiles/anssi_bp28_intermediary.profile
|
|
|
825e43 |
@@ -23,3 +23,4 @@ description: |-
|
|
|
825e43 |
|
|
|
825e43 |
selections:
|
|
|
825e43 |
- anssi:all:intermediary
|
|
|
825e43 |
+
|
|
|
825e43 |
diff --git a/products/sle15/profiles/standard.profile b/products/sle15/profiles/standard.profile
|
|
|
825e43 |
index 204804c2ee..1af0a865ef 100644
|
|
|
825e43 |
--- a/products/sle15/profiles/standard.profile
|
|
|
825e43 |
+++ b/products/sle15/profiles/standard.profile
|
|
|
825e43 |
@@ -29,9 +29,7 @@ selections:
|
|
|
825e43 |
- service_cron_enabled
|
|
|
825e43 |
- service_ntp_enabled
|
|
|
825e43 |
- service_rsyslog_enabled
|
|
|
825e43 |
- - file_owner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_ownership
|
|
|
825e43 |
- - file_groupowner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_groupownership
|
|
|
825e43 |
- rsyslog_files_permissions
|
|
|
825e43 |
- ensure_logrotate_activated
|
|
|
825e43 |
diff --git a/products/ubuntu1604/profiles/anssi_np_nt28_average.profile b/products/ubuntu1604/profiles/anssi_np_nt28_average.profile
|
|
|
825e43 |
index 600f1a6f71..4c42814719 100644
|
|
|
825e43 |
--- a/products/ubuntu1604/profiles/anssi_np_nt28_average.profile
|
|
|
825e43 |
+++ b/products/ubuntu1604/profiles/anssi_np_nt28_average.profile
|
|
|
825e43 |
@@ -22,9 +22,7 @@ selections:
|
|
|
825e43 |
- sshd_allow_only_protocol2
|
|
|
825e43 |
- var_sshd_set_keepalive=0
|
|
|
825e43 |
- sshd_set_keepalive_0
|
|
|
825e43 |
- - file_owner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_ownership
|
|
|
825e43 |
- - file_groupowner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_groupownership
|
|
|
825e43 |
- rsyslog_files_permissions
|
|
|
825e43 |
- "!rsyslog_remote_loghost"
|
|
|
825e43 |
diff --git a/products/ubuntu1604/profiles/standard.profile b/products/ubuntu1604/profiles/standard.profile
|
|
|
825e43 |
index 6fd70f0da6..93001f3bfe 100644
|
|
|
825e43 |
--- a/products/ubuntu1604/profiles/standard.profile
|
|
|
825e43 |
+++ b/products/ubuntu1604/profiles/standard.profile
|
|
|
825e43 |
@@ -34,9 +34,7 @@ selections:
|
|
|
825e43 |
- sshd_allow_only_protocol2
|
|
|
825e43 |
- var_sshd_set_keepalive=0
|
|
|
825e43 |
- sshd_set_keepalive_0
|
|
|
825e43 |
- - file_owner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_ownership
|
|
|
825e43 |
- - file_groupowner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_groupownership
|
|
|
825e43 |
- rsyslog_files_permissions
|
|
|
825e43 |
- "!rsyslog_remote_loghost"
|
|
|
825e43 |
diff --git a/products/ubuntu1804/profiles/anssi_np_nt28_average.profile b/products/ubuntu1804/profiles/anssi_np_nt28_average.profile
|
|
|
825e43 |
index 600f1a6f71..4c42814719 100644
|
|
|
825e43 |
--- a/products/ubuntu1804/profiles/anssi_np_nt28_average.profile
|
|
|
825e43 |
+++ b/products/ubuntu1804/profiles/anssi_np_nt28_average.profile
|
|
|
825e43 |
@@ -22,9 +22,7 @@ selections:
|
|
|
825e43 |
- sshd_allow_only_protocol2
|
|
|
825e43 |
- var_sshd_set_keepalive=0
|
|
|
825e43 |
- sshd_set_keepalive_0
|
|
|
825e43 |
- - file_owner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_ownership
|
|
|
825e43 |
- - file_groupowner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_groupownership
|
|
|
825e43 |
- rsyslog_files_permissions
|
|
|
825e43 |
- "!rsyslog_remote_loghost"
|
|
|
825e43 |
diff --git a/products/ubuntu1804/profiles/standard.profile b/products/ubuntu1804/profiles/standard.profile
|
|
|
825e43 |
index d587d499d8..a17117818e 100644
|
|
|
825e43 |
--- a/products/ubuntu1804/profiles/standard.profile
|
|
|
825e43 |
+++ b/products/ubuntu1804/profiles/standard.profile
|
|
|
825e43 |
@@ -32,9 +32,7 @@ selections:
|
|
|
825e43 |
- sshd_allow_only_protocol2
|
|
|
825e43 |
- var_sshd_set_keepalive=0
|
|
|
825e43 |
- sshd_set_keepalive_0
|
|
|
825e43 |
- - file_owner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_ownership
|
|
|
825e43 |
- - file_groupowner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_groupownership
|
|
|
825e43 |
- rsyslog_files_permissions
|
|
|
825e43 |
- "!rsyslog_remote_loghost"
|
|
|
825e43 |
diff --git a/products/ubuntu2004/profiles/standard.profile b/products/ubuntu2004/profiles/standard.profile
|
|
|
825e43 |
index 823a69a5d9..6ed27aa16d 100644
|
|
|
825e43 |
--- a/products/ubuntu2004/profiles/standard.profile
|
|
|
825e43 |
+++ b/products/ubuntu2004/profiles/standard.profile
|
|
|
825e43 |
@@ -31,9 +31,7 @@ selections:
|
|
|
825e43 |
- sshd_disable_empty_passwords
|
|
|
825e43 |
- var_sshd_set_keepalive=0
|
|
|
825e43 |
- sshd_set_keepalive
|
|
|
825e43 |
- - file_owner_logfiles_value=syslog
|
|
|
825e43 |
- rsyslog_files_ownership
|
|
|
825e43 |
- - file_groupowner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_groupownership
|
|
|
825e43 |
- rsyslog_files_permissions
|
|
|
825e43 |
- "!rsyslog_remote_loghost"
|
|
|
825e43 |
diff --git a/products/ubuntu2204/profiles/standard.profile b/products/ubuntu2204/profiles/standard.profile
|
|
|
825e43 |
index c8bc5369c9..1bb9f43e7d 100644
|
|
|
825e43 |
--- a/products/ubuntu2204/profiles/standard.profile
|
|
|
825e43 |
+++ b/products/ubuntu2204/profiles/standard.profile
|
|
|
825e43 |
@@ -31,9 +31,7 @@ selections:
|
|
|
825e43 |
- sshd_disable_empty_passwords
|
|
|
825e43 |
- var_sshd_set_keepalive=0
|
|
|
825e43 |
- sshd_set_keepalive
|
|
|
825e43 |
- - file_owner_logfiles_value=syslog
|
|
|
825e43 |
- rsyslog_files_ownership
|
|
|
825e43 |
- - file_groupowner_logfiles_value=adm
|
|
|
825e43 |
- rsyslog_files_groupownership
|
|
|
825e43 |
- rsyslog_files_permissions
|
|
|
825e43 |
- "!rsyslog_remote_loghost"
|
|
|
825e43 |
diff --git a/shared/references/cce-sle12-avail.txt b/shared/references/cce-sle12-avail.txt
|
|
|
825e43 |
index c119834759..4e0a76f8de 100644
|
|
|
825e43 |
--- a/shared/references/cce-sle12-avail.txt
|
|
|
825e43 |
+++ b/shared/references/cce-sle12-avail.txt
|
|
|
825e43 |
@@ -54,7 +54,6 @@ CCE-92375-5
|
|
|
825e43 |
CCE-92376-3
|
|
|
825e43 |
CCE-92377-1
|
|
|
825e43 |
CCE-92378-9
|
|
|
825e43 |
-CCE-92379-7
|
|
|
825e43 |
CCE-92380-5
|
|
|
825e43 |
CCE-92381-3
|
|
|
825e43 |
CCE-92382-1
|
|
|
825e43 |
diff --git a/shared/references/cce-sle15-avail.txt b/shared/references/cce-sle15-avail.txt
|
|
|
825e43 |
index d04c40d31f..e39dae033e 100644
|
|
|
825e43 |
--- a/shared/references/cce-sle15-avail.txt
|
|
|
825e43 |
+++ b/shared/references/cce-sle15-avail.txt
|
|
|
825e43 |
@@ -17,7 +17,6 @@ CCE-92492-8
|
|
|
825e43 |
CCE-92493-6
|
|
|
825e43 |
CCE-92495-1
|
|
|
825e43 |
CCE-92496-9
|
|
|
825e43 |
-CCE-92497-7
|
|
|
825e43 |
CCE-92498-5
|
|
|
825e43 |
CCE-92499-3
|
|
|
825e43 |
CCE-92500-8
|
|
|
825e43 |
diff --git a/shared/templates/rsyslog_logfiles_attributes_modify/ansible.template b/shared/templates/rsyslog_logfiles_attributes_modify/ansible.template
|
|
|
825e43 |
new file mode 100644
|
|
|
825e43 |
index 0000000000..fc9e8844b6
|
|
|
825e43 |
--- /dev/null
|
|
|
825e43 |
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/ansible.template
|
|
|
825e43 |
@@ -0,0 +1,68 @@
|
|
|
825e43 |
+# platform = multi_platform_all
|
|
|
825e43 |
+# reboot = false
|
|
|
825e43 |
+# strategy = configure
|
|
|
825e43 |
+# complexity = low
|
|
|
825e43 |
+# disruption = medium
|
|
|
825e43 |
+
|
|
|
825e43 |
+- name: '{{{ rule_title }}} - Set rsyslog logfile configuration facts'
|
|
|
825e43 |
+ ansible.builtin.set_fact:
|
|
|
825e43 |
+ rsyslog_etc_config: "/etc/rsyslog.conf"
|
|
|
825e43 |
+
|
|
|
825e43 |
+# * And also the log file paths listed after rsyslog's $IncludeConfig directive
|
|
|
825e43 |
+# (store the result into array for the case there's shell glob used as value of IncludeConfig)
|
|
|
825e43 |
+- name: '{{{ rule_title }}} - Get IncludeConfig directive'
|
|
|
825e43 |
+ ansible.builtin.shell: |
|
|
|
825e43 |
+ set -o pipefail
|
|
|
825e43 |
+ grep -e '$IncludeConfig' {{ rsyslog_etc_config }} | cut -d ' ' -f 2 || true
|
|
|
825e43 |
+ register: rsyslog_old_inc
|
|
|
825e43 |
+ changed_when: False
|
|
|
825e43 |
+
|
|
|
825e43 |
+- name: '{{{ rule_title }}} - Get include files directives'
|
|
|
825e43 |
+ ansible.builtin.shell: |
|
|
|
825e43 |
+ set -o pipefail
|
|
|
825e43 |
+ grep -oP '^\s*include\s*\(\s*file.*' {{ rsyslog_etc_config }} |cut -d"\"" -f 2 || true
|
|
|
825e43 |
+ register: rsyslog_new_inc
|
|
|
825e43 |
+ changed_when: False
|
|
|
825e43 |
+
|
|
|
825e43 |
+- name: '{{{ rule_title }}} - Aggregate rsyslog includes'
|
|
|
825e43 |
+ ansible.builtin.set_fact:
|
|
|
825e43 |
+ include_config_output: "{{ rsyslog_old_inc.stdout_lines + rsyslog_new_inc.stdout_lines }}"
|
|
|
825e43 |
+
|
|
|
825e43 |
+- name: '{{{ rule_title }}} - List all config files'
|
|
|
825e43 |
+ ansible.builtin.find:
|
|
|
825e43 |
+ paths: "{{ include_config_output | list | map('dirname') }}"
|
|
|
825e43 |
+ patterns: "{{ include_config_output | list | map('basename') }}"
|
|
|
825e43 |
+ hidden: no
|
|
|
825e43 |
+ follow: yes
|
|
|
825e43 |
+ register: rsyslog_config_files
|
|
|
825e43 |
+ failed_when: False
|
|
|
825e43 |
+ changed_when: False
|
|
|
825e43 |
+
|
|
|
825e43 |
+- name: '{{{ rule_title }}} - Extract log files old format'
|
|
|
825e43 |
+ ansible.builtin.shell: |
|
|
|
825e43 |
+ set -o pipefail
|
|
|
825e43 |
+ grep -oP '^[^(\s|#|\$)]+[\s]+.*[\s]+-?(/+[^:;\s]+);*\.*$' {{ item }} |awk '{print $NF}'|sed -e 's/^-//' || true
|
|
|
825e43 |
+ loop: "{{ rsyslog_config_files.files|map(attribute='path')|list|flatten|unique + [ rsyslog_etc_config ] }}"
|
|
|
825e43 |
+ register: log_files_old
|
|
|
825e43 |
+ changed_when: False
|
|
|
825e43 |
+
|
|
|
825e43 |
+- name: '{{{ rule_title }}} - Extract log files new format'
|
|
|
825e43 |
+ ansible.builtin.shell: |
|
|
|
825e43 |
+ set -o pipefail
|
|
|
825e43 |
+ grep -ozP "action\s*\(\s*type\s*=\s*\"omfile\"[^\)]*\)" {{ item }} | grep -aoP "File\s*=\s*\"([/[:alnum:][:punct:]]*)\"\s*\)"|grep -oE "\"([/[:alnum:][:punct:]]*)\"" |tr -d "\""|| true
|
|
|
825e43 |
+ loop: "{{ rsyslog_config_files.files|map(attribute='path')|list|flatten|unique + [ rsyslog_etc_config ] }}"
|
|
|
825e43 |
+ register: log_files_new
|
|
|
825e43 |
+ changed_when: False
|
|
|
825e43 |
+
|
|
|
825e43 |
+- name: '{{{ rule_title }}} - Sum all log files found'
|
|
|
825e43 |
+ ansible.builtin.set_fact:
|
|
|
825e43 |
+ log_files: "{{ log_files_new.results|map(attribute='stdout_lines')|list|flatten|unique + log_files_old.results|map(attribute='stdout_lines')|list|flatten|unique }}"
|
|
|
825e43 |
+
|
|
|
825e43 |
+- name: '{{{ rule_title }}} -Setup log files attribute'
|
|
|
825e43 |
+ ansible.builtin.file:
|
|
|
825e43 |
+ path: "{{ item }}"
|
|
|
825e43 |
+ owner: '{{ ( "{{{ ATTRIBUTE }}}" is match("owner")) | ternary({{{ VALUE }}}, omit) }}'
|
|
|
825e43 |
+ group: '{{ ( "{{{ ATTRIBUTE }}}" is match("groupowner")) | ternary({{{ VALUE }}} , omit) }}'
|
|
|
825e43 |
+ state: file
|
|
|
825e43 |
+ loop: "{{ log_files | list | flatten | unique }}"
|
|
|
825e43 |
+ failed_when: false
|
|
|
825e43 |
diff --git a/shared/templates/rsyslog_logfiles_attributes_modify/bash.template b/shared/templates/rsyslog_logfiles_attributes_modify/bash.template
|
|
|
825e43 |
new file mode 100644
|
|
|
825e43 |
index 0000000000..ab4a563dc5
|
|
|
825e43 |
--- /dev/null
|
|
|
825e43 |
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/bash.template
|
|
|
825e43 |
@@ -0,0 +1,110 @@
|
|
|
825e43 |
+# platform = multi_platform_all
|
|
|
825e43 |
+
|
|
|
825e43 |
+# List of log file paths to be inspected for correct permissions
|
|
|
825e43 |
+# * Primarily inspect log file paths listed in /etc/rsyslog.conf
|
|
|
825e43 |
+RSYSLOG_ETC_CONFIG="/etc/rsyslog.conf"
|
|
|
825e43 |
+# * And also the log file paths listed after rsyslog's $IncludeConfig directive
|
|
|
825e43 |
+# (store the result into array for the case there's shell glob used as value of IncludeConfig)
|
|
|
825e43 |
+readarray -t OLD_INC < <(grep -e "\$IncludeConfig[[:space:]]\+[^[:space:];]\+" /etc/rsyslog.conf | cut -d ' ' -f 2)
|
|
|
825e43 |
+readarray -t RSYSLOG_INCLUDE_CONFIG < <(for INCPATH in "${OLD_INC[@]}"; do eval printf '%s\\n' "${INCPATH}"; done)
|
|
|
825e43 |
+readarray -t NEW_INC < <(awk '/)/{f=0} /include\(/{f=1} f{nf=gensub("^(include\\(|\\s*)file=\"(\\S+)\".*","\\2",1); if($0!=nf){print nf}}' /etc/rsyslog.conf)
|
|
|
825e43 |
+readarray -t RSYSLOG_INCLUDE < <(for INCPATH in "${NEW_INC[@]}"; do eval printf '%s\\n' "${INCPATH}"; done)
|
|
|
825e43 |
+
|
|
|
825e43 |
+# Declare an array to hold the final list of different log file paths
|
|
|
825e43 |
+declare -a LOG_FILE_PATHS
|
|
|
825e43 |
+
|
|
|
825e43 |
+# Array to hold all rsyslog config entries
|
|
|
825e43 |
+RSYSLOG_CONFIGS=()
|
|
|
825e43 |
+RSYSLOG_CONFIGS=("${RSYSLOG_ETC_CONFIG}" "${RSYSLOG_INCLUDE_CONFIG[@]}" "${RSYSLOG_INCLUDE[@]}")
|
|
|
825e43 |
+
|
|
|
825e43 |
+# Get full list of files to be checked
|
|
|
825e43 |
+# RSYSLOG_CONFIGS may contain globs such as
|
|
|
825e43 |
+# /etc/rsyslog.d/*.conf /etc/rsyslog.d/*.frule
|
|
|
825e43 |
+# So, loop over the entries in RSYSLOG_CONFIGS and use find to get the list of included files.
|
|
|
825e43 |
+RSYSLOG_CONFIG_FILES=()
|
|
|
825e43 |
+for ENTRY in "${RSYSLOG_CONFIGS[@]}"
|
|
|
825e43 |
+do
|
|
|
825e43 |
+ # If directory, rsyslog will search for config files in recursively.
|
|
|
825e43 |
+ # However, files in hidden sub-directories or hidden files will be ignored.
|
|
|
825e43 |
+ if [ -d "${ENTRY}" ]
|
|
|
825e43 |
+ then
|
|
|
825e43 |
+ readarray -t FINDOUT < <(find "${ENTRY}" -not -path '*/.*' -type f)
|
|
|
825e43 |
+ RSYSLOG_CONFIG_FILES+=("${FINDOUT[@]}")
|
|
|
825e43 |
+ elif [ -f "${ENTRY}" ]
|
|
|
825e43 |
+ then
|
|
|
825e43 |
+ RSYSLOG_CONFIG_FILES+=("${ENTRY}")
|
|
|
825e43 |
+ else
|
|
|
825e43 |
+ echo "Invalid include object: ${ENTRY}"
|
|
|
825e43 |
+ fi
|
|
|
825e43 |
+done
|
|
|
825e43 |
+
|
|
|
825e43 |
+# Browse each file selected above as containing paths of log files
|
|
|
825e43 |
+# ('/etc/rsyslog.conf' and '/etc/rsyslog.d/*.conf' in the default configuration)
|
|
|
825e43 |
+for LOG_FILE in "${RSYSLOG_CONFIG_FILES[@]}"
|
|
|
825e43 |
+do
|
|
|
825e43 |
+ # From each of these files extract just particular log file path(s), thus:
|
|
|
825e43 |
+ # * Ignore lines starting with space (' '), comment ('#"), or variable syntax ('$') characters,
|
|
|
825e43 |
+ # * Ignore empty lines,
|
|
|
825e43 |
+ # * Strip quotes and closing brackets from paths.
|
|
|
825e43 |
+ # * Ignore paths that match /dev|/etc.*\.conf, as those are paths, but likely not log files
|
|
|
825e43 |
+ # * From the remaining valid rows select only fields constituting a log file path
|
|
|
825e43 |
+ # Text file column is understood to represent a log file path if and only if all of the following are met:
|
|
|
825e43 |
+ # * it contains at least one slash '/' character,
|
|
|
825e43 |
+ # * it is preceded by space
|
|
|
825e43 |
+ # * it doesn't contain space (' '), colon (':'), and semicolon (';') characters
|
|
|
825e43 |
+ # Search log file for path(s) only in case it exists!
|
|
|
825e43 |
+ if [[ -f "${LOG_FILE}" ]]
|
|
|
825e43 |
+ then
|
|
|
825e43 |
+ NORMALIZED_CONFIG_FILE_LINES=$(sed -e "/^[#|$]/d" "${LOG_FILE}")
|
|
|
825e43 |
+ LINES_WITH_PATHS=$(grep '[^/]*\s\+\S*/\S\+$' <<< "${NORMALIZED_CONFIG_FILE_LINES}")
|
|
|
825e43 |
+ FILTERED_PATHS=$(awk '{if(NF>=2&&($NF~/^\//||$NF~/^-\//)){sub(/^-\//,"/",$NF);print $NF}}' <<< "${LINES_WITH_PATHS}")
|
|
|
825e43 |
+ CLEANED_PATHS=$(sed -e "s/[\"')]//g; /\\/etc.*\.conf/d; /\\/dev\\//d" <<< "${FILTERED_PATHS}")
|
|
|
825e43 |
+ MATCHED_ITEMS=$(sed -e "/^$/d" <<< "${CLEANED_PATHS}")
|
|
|
825e43 |
+ # Since above sed command might return more than one item (delimited by newline), split the particular
|
|
|
825e43 |
+ # matches entries into new array specific for this log file
|
|
|
825e43 |
+ readarray -t ARRAY_FOR_LOG_FILE <<< "$MATCHED_ITEMS"
|
|
|
825e43 |
+ # Concatenate the two arrays - previous content of $LOG_FILE_PATHS array with
|
|
|
825e43 |
+ # items from newly created array for this log file
|
|
|
825e43 |
+ LOG_FILE_PATHS+=("${ARRAY_FOR_LOG_FILE[@]}")
|
|
|
825e43 |
+ # Delete the temporary array
|
|
|
825e43 |
+ unset ARRAY_FOR_LOG_FILE
|
|
|
825e43 |
+ fi
|
|
|
825e43 |
+done
|
|
|
825e43 |
+
|
|
|
825e43 |
+# Check for RainerScript action log format which might be also multiline so grep regex is a bit curly
|
|
|
825e43 |
+# extract possibly multiline action omfile expressions
|
|
|
825e43 |
+# extract File="logfile" expression
|
|
|
825e43 |
+# match only "logfile" expression
|
|
|
825e43 |
+for LOG_FILE in "${RSYSLOG_CONFIG_FILES[@]}"
|
|
|
825e43 |
+do
|
|
|
825e43 |
+ ACTION_OMFILE_LINES=$(grep -ozP "action\s*\(\s*type\s*=\s*\"omfile\"[^\)]*\)" "${LOG_FILE}")
|
|
|
825e43 |
+ OMFILE_LINES=$(echo "${ACTION_OMFILE_LINES}"| grep -aoP "File\s*=\s*\"([/[:alnum:][:punct:]]*)\"\s*\)")
|
|
|
825e43 |
+ LOG_FILE_PATHS+=("$(echo "${OMFILE_LINES}"| grep -oE "\"([/[:alnum:][:punct:]]*)\""|tr -d "\"")")
|
|
|
825e43 |
+done
|
|
|
825e43 |
+
|
|
|
825e43 |
+FILE_PARAM="{{{ ATTRIBUTE }}}"
|
|
|
825e43 |
+FILE_CMD=""
|
|
|
825e43 |
+case "$FILE_PARAM" in
|
|
|
825e43 |
+ "groupowner")
|
|
|
825e43 |
+ FILE_CMD=$(which chgrp)
|
|
|
825e43 |
+ ;;
|
|
|
825e43 |
+ "owner")
|
|
|
825e43 |
+ FILE_CMD=$(which chown)
|
|
|
825e43 |
+ ;;
|
|
|
825e43 |
+ *)
|
|
|
825e43 |
+ echo -n "Not supported file attribute! "
|
|
|
825e43 |
+ exit 1
|
|
|
825e43 |
+ ;;
|
|
|
825e43 |
+esac
|
|
|
825e43 |
+
|
|
|
825e43 |
+# Correct the form o
|
|
|
825e43 |
+for LOG_FILE_PATH in "${LOG_FILE_PATHS[@]}"
|
|
|
825e43 |
+do
|
|
|
825e43 |
+ # Sanity check - if particular $LOG_FILE_PATH is empty string, skip it from further processing
|
|
|
825e43 |
+ if [ -z "$LOG_FILE_PATH" ]
|
|
|
825e43 |
+ then
|
|
|
825e43 |
+ continue
|
|
|
825e43 |
+ fi
|
|
|
825e43 |
+
|
|
|
825e43 |
+ $FILE_CMD "+{{{ VALUE }}}" "$LOG_FILE_PATH"
|
|
|
825e43 |
+done
|
|
|
825e43 |
diff --git a/shared/templates/rsyslog_logfiles_attributes_modify/oval.template b/shared/templates/rsyslog_logfiles_attributes_modify/oval.template
|
|
|
825e43 |
new file mode 100644
|
|
|
825e43 |
index 0000000000..4f288df1c9
|
|
|
825e43 |
--- /dev/null
|
|
|
825e43 |
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/oval.template
|
|
|
825e43 |
@@ -0,0 +1,137 @@
|
|
|
825e43 |
+<def-group oval_version="5.11">
|
|
|
825e43 |
+ <definition class="compliance" id="{{{_RULE_ID }}}" version="1">
|
|
|
825e43 |
+ {{{ oval_metadata("All syslog log files should have appropriate ownership.") }}}
|
|
|
825e43 |
+ <criteria operator="AND">
|
|
|
825e43 |
+ {{% if product in ["debian10", "debian11", "ubuntu1604"] %}}
|
|
|
825e43 |
+
|
|
|
825e43 |
+ definition_ref="package_rsyslog_installed" />
|
|
|
825e43 |
+ {{% endif %}}
|
|
|
825e43 |
+
|
|
|
825e43 |
+ {{{ ATTRIBUTE }}}" test_ref="test_{{{ _RULE_ID }}}" />
|
|
|
825e43 |
+ </criteria>
|
|
|
825e43 |
+
|
|
|
825e43 |
+ </definition>
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+ v8.33.0) values. -->
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+ comment="rsyslog's $IncludeConfig directive and include() object values" version="1">
|
|
|
825e43 |
+ <ind:filepath>/etc/rsyslog.conf</ind:filepath>
|
|
|
825e43 |
+
|
|
|
825e43 |
+ operation="pattern match">^(?:include\([\n\s]*file="([^\s;]+)".*|\$IncludeConfig[\s]+([^\s;]+))$</ind:pattern>
|
|
|
825e43 |
+ <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
|
|
|
825e43 |
+ </ind:textfilecontent54_object>
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+ comment="$IncludeConfig value converted to regex">
|
|
|
825e43 |
+ <unique>
|
|
|
825e43 |
+ <glob_to_regex>
|
|
|
825e43 |
+
|
|
|
825e43 |
+ object_ref="object_{{{ _RULE_ID }}}_include_config_value" />
|
|
|
825e43 |
+ </glob_to_regex>
|
|
|
825e43 |
+ </unique>
|
|
|
825e43 |
+ </local_variable>
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+ If the variable has no values, there won't be any objects -->
|
|
|
825e43 |
+
|
|
|
825e43 |
+ comment="Make variable object from regex variable" version="1">
|
|
|
825e43 |
+ <ind:var_ref>var_{{{ _RULE_ID }}}_include_config_regex</ind:var_ref>
|
|
|
825e43 |
+ </ind:variable_object>
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+ version="1" comment="Locations of all rsyslog configuration files as collection">
|
|
|
825e43 |
+ <literal_component datatype="string">^/etc/rsyslog.conf$</literal_component>
|
|
|
825e43 |
+ </local_variable>
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+ comment="Make variable object for use" version="1">
|
|
|
825e43 |
+ <ind:var_ref>var_{{{ _RULE_ID }}}_syslog_config</ind:var_ref>
|
|
|
825e43 |
+ </ind:variable_object>
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+ We do it this way to avoid referencing an empty variable in a state comparison, which
|
|
|
825e43 |
+ will cause a test to evaluate to fail. Combining an empty set of objects is fine though -->
|
|
|
825e43 |
+
|
|
|
825e43 |
+ comment="Filter out empty string" version="1">
|
|
|
825e43 |
+ <set>
|
|
|
825e43 |
+ <object_reference>object_var_{{{ _RULE_ID }}}_include_config_regex</object_reference>
|
|
|
825e43 |
+ <object_reference>object_var_{{{ _RULE_ID }}}_syslog_config</object_reference>
|
|
|
825e43 |
+ </set>
|
|
|
825e43 |
+ </ind:variable_object>
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+ a list of objects won't do. So we make a local_variable from the variable_objects. -->
|
|
|
825e43 |
+
|
|
|
825e43 |
+ comment="Locations of all rsyslog configuration files as collection">
|
|
|
825e43 |
+ <object_component object_ref="object_var_{{{ _RULE_ID }}}_all_log_files" item_field="value"/>
|
|
|
825e43 |
+ </local_variable>
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+ that rsyslog's configuration file to select file paths for log files directives
|
|
|
825e43 |
+ -->
|
|
|
825e43 |
+
|
|
|
825e43 |
+ comment="All rsyslog configuration files" version="1">
|
|
|
825e43 |
+
|
|
|
825e43 |
+ var_check="at least one" />
|
|
|
825e43 |
+
|
|
|
825e43 |
+ to constitute a log file path if all of the following conditions are met:
|
|
|
825e43 |
+ * the string represents a regular file on particular file system
|
|
|
825e43 |
+ (verified via corresponding file_state below),
|
|
|
825e43 |
+ * the chunk of text is in the last column in the row,
|
|
|
825e43 |
+ (possibly suffixed by ';' character and rsyslog Template name),
|
|
|
825e43 |
+ * contains at least one slash '/' character, and simultaneously
|
|
|
825e43 |
+ doesn't contain any of ';', ':' and space characters,
|
|
|
825e43 |
+ * the chunk was retrieved from a row not starting with space, '#',
|
|
|
825e43 |
+ or '$' characters
|
|
|
825e43 |
+ -->
|
|
|
825e43 |
+
|
|
|
825e43 |
+ operation="pattern match">^\s*[^(\s|#|\$)]+\s+-?[\w\(="\s]*(\/[^:;\s"]+)+.*$</ind:pattern>
|
|
|
825e43 |
+ <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
|
|
|
825e43 |
+ <filter action="exclude">state_{{{ _RULE_ID }}}_ownership_ignore_include_paths</filter>
|
|
|
825e43 |
+ </ind:textfilecontent54_object>
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+ comment="ignore" version="1">
|
|
|
825e43 |
+
|
|
|
825e43 |
+ include() or $IncludeConfig statements.
|
|
|
825e43 |
+ These paths are conf files, not log files. Their groupownership don't need to be as
|
|
|
825e43 |
+ required for log files, thus, lets exclude them from the list of objects found
|
|
|
825e43 |
+ -->
|
|
|
825e43 |
+
|
|
|
825e43 |
+ operation="pattern match">(?:file="[^\s;]+"|\$IncludeConfig[\s]+[^\s;]+|\/dev\/.*)</ind:text>
|
|
|
825e43 |
+ </ind:textfilecontent54_state>
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+ retrieved from the different rsyslog configuration files
|
|
|
825e43 |
+ -->
|
|
|
825e43 |
+
|
|
|
825e43 |
+ comment="File paths of all rsyslog configuration files">
|
|
|
825e43 |
+ <object_component item_field="subexpression" object_ref="object_{{{ _RULE_ID }}}_log_files_paths" />
|
|
|
825e43 |
+ </local_variable>
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+ comment="System log files are owned by the appropriate group">
|
|
|
825e43 |
+ <unix:object object_ref="object_rsyslog_files_{{{ _RULE_ID }}}_ownership" />
|
|
|
825e43 |
+ <unix:state state_ref="state_{{{ _RULE_ID }}}" />
|
|
|
825e43 |
+ </unix:file_test>
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+ comment="Various system log files" version="1">
|
|
|
825e43 |
+
|
|
|
825e43 |
+ var_check="at least one" />
|
|
|
825e43 |
+ </unix:file_object>
|
|
|
825e43 |
+
|
|
|
825e43 |
+ <unix:file_state id="state_{{{ _RULE_ID }}}" version="1">
|
|
|
825e43 |
+ <unix:type operation="equals">regular</unix:type>
|
|
|
825e43 |
+ {{% if ATTRIBUTE == "groupowner" %}}
|
|
|
825e43 |
+ <unix:group_id datatype="int">{{{ VALUE }}}</unix:group_id>
|
|
|
825e43 |
+ {{% else %}}
|
|
|
825e43 |
+ <unix:user_id datatype="int">{{{ VALUE }}}</unix:user_id>
|
|
|
825e43 |
+ {{% endif %}}
|
|
|
825e43 |
+ </unix:file_state>
|
|
|
825e43 |
+
|
|
|
825e43 |
+</def-group>
|
|
|
825e43 |
diff --git a/shared/templates/rsyslog_logfiles_attributes_modify/template.yml b/shared/templates/rsyslog_logfiles_attributes_modify/template.yml
|
|
|
825e43 |
new file mode 100644
|
|
|
825e43 |
index 0000000000..b57de6fbb6
|
|
|
825e43 |
--- /dev/null
|
|
|
825e43 |
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/template.yml
|
|
|
825e43 |
@@ -0,0 +1,4 @@
|
|
|
825e43 |
+supported_languages:
|
|
|
825e43 |
+ - ansible
|
|
|
825e43 |
+ - bash
|
|
|
825e43 |
+ - oval
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/IncludeConfig_is_other.fail.sh b/shared/templates/rsyslog_logfiles_attributes_modify/tests/IncludeConfig_is_other.fail.sh
|
|
|
825e43 |
similarity index 75%
|
|
|
825e43 |
rename from linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/IncludeConfig_is_other.fail.sh
|
|
|
825e43 |
rename to shared/templates/rsyslog_logfiles_attributes_modify/tests/IncludeConfig_is_other.fail.sh
|
|
|
825e43 |
index 6c82a1942f..db7e5261eb 100755
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/IncludeConfig_is_other.fail.sh
|
|
|
825e43 |
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/tests/IncludeConfig_is_other.fail.sh
|
|
|
825e43 |
@@ -6,8 +6,16 @@
|
|
|
825e43 |
|
|
|
825e43 |
source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
|
|
|
825e43 |
+{{% if ATTRIBUTE == "owner" %}}
|
|
|
825e43 |
+ADDCOMMAND="useradd"
|
|
|
825e43 |
+CHATTR="chown"
|
|
|
825e43 |
+{{% else %}}
|
|
|
825e43 |
+ADDCOMMAND="groupadd"
|
|
|
825e43 |
+CHATTR="chgrp"
|
|
|
825e43 |
+{{% endif %}}
|
|
|
825e43 |
+
|
|
|
825e43 |
USER_TEST=testssg
|
|
|
825e43 |
-useradd $USER_TEST
|
|
|
825e43 |
+$ADDCOMMAND $USER_TEST
|
|
|
825e43 |
|
|
|
825e43 |
USER_ROOT=root
|
|
|
825e43 |
|
|
|
825e43 |
@@ -15,8 +23,8 @@ USER_ROOT=root
|
|
|
825e43 |
create_rsyslog_test_logs 2
|
|
|
825e43 |
|
|
|
825e43 |
# setup test log files ownership
|
|
|
825e43 |
-chown $USER_ROOT ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-chown $USER_TEST ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
+$CHATTR $USER_ROOT ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
+$CHATTR $USER_TEST ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
|
|
|
825e43 |
# create test configuration file
|
|
|
825e43 |
test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/IncludeConfig_is_root.pass.sh b/shared/templates/rsyslog_logfiles_attributes_modify/tests/IncludeConfig_is_root.pass.sh
|
|
|
825e43 |
similarity index 81%
|
|
|
825e43 |
rename from linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/IncludeConfig_is_root.pass.sh
|
|
|
825e43 |
rename to shared/templates/rsyslog_logfiles_attributes_modify/tests/IncludeConfig_is_root.pass.sh
|
|
|
825e43 |
index b24e5e1699..b03268fe3e 100755
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/IncludeConfig_is_root.pass.sh
|
|
|
825e43 |
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/tests/IncludeConfig_is_root.pass.sh
|
|
|
825e43 |
@@ -6,14 +6,20 @@
|
|
|
825e43 |
|
|
|
825e43 |
source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
|
|
|
825e43 |
+{{% if ATTRIBUTE == "owner" %}}
|
|
|
825e43 |
+CHATTR="chown"
|
|
|
825e43 |
+{{% else %}}
|
|
|
825e43 |
+CHATTR="chgrp"
|
|
|
825e43 |
+{{% endif %}}
|
|
|
825e43 |
+
|
|
|
825e43 |
USER=root
|
|
|
825e43 |
|
|
|
825e43 |
# setup test data
|
|
|
825e43 |
create_rsyslog_test_logs 2
|
|
|
825e43 |
|
|
|
825e43 |
# setup test log files ownership
|
|
|
825e43 |
-chown $USER ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-chown $USER ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
+$CHATTR $USER ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
+$CHATTR $USER ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
|
|
|
825e43 |
# create test configuration file
|
|
|
825e43 |
test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/include_is_other.fail.sh b/shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_other.fail.sh
|
|
|
825e43 |
similarity index 75%
|
|
|
825e43 |
rename from linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/include_is_other.fail.sh
|
|
|
825e43 |
rename to shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_other.fail.sh
|
|
|
825e43 |
index 18f43c6927..d79ae23cfc 100755
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/include_is_other.fail.sh
|
|
|
825e43 |
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_other.fail.sh
|
|
|
825e43 |
@@ -6,8 +6,16 @@
|
|
|
825e43 |
|
|
|
825e43 |
source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
|
|
|
825e43 |
+{{% if ATTRIBUTE == "owner" %}}
|
|
|
825e43 |
+ADDCOMMAND="useradd"
|
|
|
825e43 |
+CHATTR="chown"
|
|
|
825e43 |
+{{% else %}}
|
|
|
825e43 |
+ADDCOMMAND="groupadd"
|
|
|
825e43 |
+CHATTR="chgrp"
|
|
|
825e43 |
+{{% endif %}}
|
|
|
825e43 |
+
|
|
|
825e43 |
USER_TEST=testssg
|
|
|
825e43 |
-useradd $USER_TEST
|
|
|
825e43 |
+$ADDCOMMAND $USER_TEST
|
|
|
825e43 |
|
|
|
825e43 |
USER_ROOT=root
|
|
|
825e43 |
|
|
|
825e43 |
@@ -15,8 +23,8 @@ USER_ROOT=root
|
|
|
825e43 |
create_rsyslog_test_logs 2
|
|
|
825e43 |
|
|
|
825e43 |
# setup test log files ownership
|
|
|
825e43 |
-chown $USER_ROOT ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-chown $USER_TEST ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
+$CHATTR $USER_ROOT ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
+$CHATTR $USER_TEST ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
|
|
|
825e43 |
# create test configuration file
|
|
|
825e43 |
test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_root_IncludeConfig_is_root.pass.sh b/shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_other_IncludeConfig_is_other_RainerLogClause.fail.sh
|
|
|
825e43 |
old mode 100755
|
|
|
825e43 |
new mode 100644
|
|
|
825e43 |
similarity index 50%
|
|
|
825e43 |
rename from linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_root_IncludeConfig_is_root.pass.sh
|
|
|
825e43 |
rename to shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_other_IncludeConfig_is_other_RainerLogClause.fail.sh
|
|
|
825e43 |
index 05dd50ed24..7869a180a8
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_root_IncludeConfig_is_root.pass.sh
|
|
|
825e43 |
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_other_IncludeConfig_is_other_RainerLogClause.fail.sh
|
|
|
825e43 |
@@ -1,20 +1,31 @@
|
|
|
825e43 |
#!/bin/bash
|
|
|
825e43 |
# platform = Red Hat Enterprise Linux 8,multi_platform_fedora,Oracle Linux 8,multi_platform_sle
|
|
|
825e43 |
|
|
|
825e43 |
-# Check rsyslog.conf with root group-owner log from rules and
|
|
|
825e43 |
-# root group-owner log from include() passes.
|
|
|
825e43 |
+# Check rsyslog.conf with root user log from rules and
|
|
|
825e43 |
+# root user log from include() passes.
|
|
|
825e43 |
|
|
|
825e43 |
source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
|
|
|
825e43 |
-GROUP=root
|
|
|
825e43 |
+{{% if ATTRIBUTE == "owner" %}}
|
|
|
825e43 |
+ADDCOMMAND="useradd"
|
|
|
825e43 |
+CHATTR="chown"
|
|
|
825e43 |
+{{% else %}}
|
|
|
825e43 |
+ADDCOMMAND="groupadd"
|
|
|
825e43 |
+CHATTR="chgrp"
|
|
|
825e43 |
+{{% endif %}}
|
|
|
825e43 |
+
|
|
|
825e43 |
+USER_TEST=testssg
|
|
|
825e43 |
+$ADDCOMMAND $USER_TEST
|
|
|
825e43 |
+
|
|
|
825e43 |
+USER=root
|
|
|
825e43 |
|
|
|
825e43 |
# setup test data
|
|
|
825e43 |
create_rsyslog_test_logs 3
|
|
|
825e43 |
|
|
|
825e43 |
# setup test log files ownership
|
|
|
825e43 |
-chgrp $GROUP ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-chgrp $GROUP ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
-chgrp $GROUP ${RSYSLOG_TEST_LOGS[2]}
|
|
|
825e43 |
+$CHATTR $USER_TEST ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
+$CHATTR $USER_TEST ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
+$CHATTR $USER_TEST ${RSYSLOG_TEST_LOGS[2]}
|
|
|
825e43 |
|
|
|
825e43 |
# create test configuration file
|
|
|
825e43 |
test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
825e43 |
@@ -28,13 +39,25 @@ EOF
|
|
|
825e43 |
|
|
|
825e43 |
# create test2 configuration file
|
|
|
825e43 |
test_conf2=${RSYSLOG_TEST_DIR}/test2.conf
|
|
|
825e43 |
+{{% if ATTRIBUTE == "owner" %}}
|
|
|
825e43 |
+cat << EOF > ${test_conf2}
|
|
|
825e43 |
+# rsyslog configuration file
|
|
|
825e43 |
+
|
|
|
825e43 |
+#### RULES ####
|
|
|
825e43 |
+
|
|
|
825e43 |
+
|
|
|
825e43 |
+*.* action(type="omfile" FileCreateMode="0640" fileOwner="$USER_TEST" fileGroup="root" File="${RSYSLOG_TEST_LOGS[2]}")
|
|
|
825e43 |
+EOF
|
|
|
825e43 |
+{{% else %}}
|
|
|
825e43 |
cat << EOF > ${test_conf2}
|
|
|
825e43 |
# rsyslog configuration file
|
|
|
825e43 |
|
|
|
825e43 |
#### RULES ####
|
|
|
825e43 |
|
|
|
825e43 |
-*.* ${RSYSLOG_TEST_LOGS[2]}
|
|
|
825e43 |
+
|
|
|
825e43 |
+*.* action(type="omfile" FileCreateMode="0640" fileOwner="root" fileGroup="$USER_TEST" File="${RSYSLOG_TEST_LOGS[2]}")
|
|
|
825e43 |
EOF
|
|
|
825e43 |
+{{% endif %}}
|
|
|
825e43 |
|
|
|
825e43 |
# create rsyslog.conf configuration file
|
|
|
825e43 |
cat << EOF > $RSYSLOG_CONF
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/include_is_root.pass.sh b/shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_root.pass.sh
|
|
|
825e43 |
similarity index 81%
|
|
|
825e43 |
rename from linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/include_is_root.pass.sh
|
|
|
825e43 |
rename to shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_root.pass.sh
|
|
|
825e43 |
index 69dead5135..e80395ca99 100755
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/include_is_root.pass.sh
|
|
|
825e43 |
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_root.pass.sh
|
|
|
825e43 |
@@ -6,14 +6,21 @@
|
|
|
825e43 |
|
|
|
825e43 |
source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
|
|
|
825e43 |
+
|
|
|
825e43 |
+{{% if ATTRIBUTE == "owner" %}}
|
|
|
825e43 |
+CHATTR="chown"
|
|
|
825e43 |
+{{% else %}}
|
|
|
825e43 |
+CHATTR="chgrp"
|
|
|
825e43 |
+{{% endif %}}
|
|
|
825e43 |
+
|
|
|
825e43 |
USER=root
|
|
|
825e43 |
|
|
|
825e43 |
# setup test data
|
|
|
825e43 |
create_rsyslog_test_logs 2
|
|
|
825e43 |
|
|
|
825e43 |
# setup test log files ownership
|
|
|
825e43 |
-chown $USER ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-chown $USER ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
+$CHATTR $USER ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
+$CHATTR $USER ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
|
|
|
825e43 |
# create test configuration file
|
|
|
825e43 |
test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/include_is_root_IncludeConfig_is_other.fail.sh b/shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_root_IncludeConfig_is_other.fail.sh
|
|
|
825e43 |
similarity index 77%
|
|
|
825e43 |
rename from linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/include_is_root_IncludeConfig_is_other.fail.sh
|
|
|
825e43 |
rename to shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_root_IncludeConfig_is_other.fail.sh
|
|
|
825e43 |
index e725fb4d54..e7b4905dc5 100755
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/include_is_root_IncludeConfig_is_other.fail.sh
|
|
|
825e43 |
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_root_IncludeConfig_is_other.fail.sh
|
|
|
825e43 |
@@ -6,18 +6,26 @@
|
|
|
825e43 |
|
|
|
825e43 |
source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
|
|
|
825e43 |
+{{% if ATTRIBUTE == "owner" %}}
|
|
|
825e43 |
+ADDCOMMAND="useradd"
|
|
|
825e43 |
+CHATTR="chown"
|
|
|
825e43 |
+{{% else %}}
|
|
|
825e43 |
+ADDCOMMAND="groupadd"
|
|
|
825e43 |
+CHATTR="chgrp"
|
|
|
825e43 |
+{{% endif %}}
|
|
|
825e43 |
+
|
|
|
825e43 |
USER_ROOT=root
|
|
|
825e43 |
|
|
|
825e43 |
USER_TEST=testssg
|
|
|
825e43 |
-useradd $USER_TEST
|
|
|
825e43 |
+$ADDCOMMAND $USER_TEST
|
|
|
825e43 |
|
|
|
825e43 |
# setup test data
|
|
|
825e43 |
create_rsyslog_test_logs 3
|
|
|
825e43 |
|
|
|
825e43 |
# setup test log files ownership
|
|
|
825e43 |
-chown $USER_ROOT ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-chown $USER_ROOT ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
-chown $USER_TEST ${RSYSLOG_TEST_LOGS[2]}
|
|
|
825e43 |
+$CHATTR $USER_ROOT ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
+$CHATTR $USER_ROOT ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
+$CHATTR $USER_TEST ${RSYSLOG_TEST_LOGS[2]}
|
|
|
825e43 |
|
|
|
825e43 |
# create test configuration file
|
|
|
825e43 |
test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/include_is_root_IncludeConfig_is_root.pass.sh b/shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_root_IncludeConfig_is_root.pass.sh
|
|
|
825e43 |
similarity index 82%
|
|
|
825e43 |
rename from linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/include_is_root_IncludeConfig_is_root.pass.sh
|
|
|
825e43 |
rename to shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_root_IncludeConfig_is_root.pass.sh
|
|
|
825e43 |
index ca47d453c1..6389e6ea3b 100755
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/include_is_root_IncludeConfig_is_root.pass.sh
|
|
|
825e43 |
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_root_IncludeConfig_is_root.pass.sh
|
|
|
825e43 |
@@ -6,15 +6,21 @@
|
|
|
825e43 |
|
|
|
825e43 |
source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
|
|
|
825e43 |
+{{% if ATTRIBUTE == "owner" %}}
|
|
|
825e43 |
+CHATTR="chown"
|
|
|
825e43 |
+{{% else %}}
|
|
|
825e43 |
+CHATTR="chgrp"
|
|
|
825e43 |
+{{% endif %}}
|
|
|
825e43 |
+
|
|
|
825e43 |
USER=root
|
|
|
825e43 |
|
|
|
825e43 |
# setup test data
|
|
|
825e43 |
create_rsyslog_test_logs 3
|
|
|
825e43 |
|
|
|
825e43 |
# setup test log files ownership
|
|
|
825e43 |
-chown $USER ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-chown $USER ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
-chown $USER ${RSYSLOG_TEST_LOGS[2]}
|
|
|
825e43 |
+$CHATTR $USER ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
+$CHATTR $USER ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
+$CHATTR $USER ${RSYSLOG_TEST_LOGS[2]}
|
|
|
825e43 |
|
|
|
825e43 |
# create test configuration file
|
|
|
825e43 |
test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_root_IncludeConfig_is_other.fail.sh b/shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_root_IncludeConfig_is_root_RainerLogClause.pass.sh
|
|
|
825e43 |
similarity index 65%
|
|
|
825e43 |
rename from linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_root_IncludeConfig_is_other.fail.sh
|
|
|
825e43 |
rename to shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_root_IncludeConfig_is_root_RainerLogClause.pass.sh
|
|
|
825e43 |
index 9747e0b28b..6b81a77c2f 100755
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/tests/include_is_root_IncludeConfig_is_other.fail.sh
|
|
|
825e43 |
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/tests/include_is_root_IncludeConfig_is_root_RainerLogClause.pass.sh
|
|
|
825e43 |
@@ -1,23 +1,26 @@
|
|
|
825e43 |
#!/bin/bash
|
|
|
825e43 |
# platform = Red Hat Enterprise Linux 8,multi_platform_fedora,Oracle Linux 8,multi_platform_sle
|
|
|
825e43 |
|
|
|
825e43 |
-# Check rsyslog.conf with root group-owner log from rules and
|
|
|
825e43 |
-# non root group-owner log from include() fails.
|
|
|
825e43 |
+# Check rsyslog.conf with root user log from rules and
|
|
|
825e43 |
+# root user log from include() passes.
|
|
|
825e43 |
|
|
|
825e43 |
source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
|
|
|
825e43 |
-GROUP_ROOT=root
|
|
|
825e43 |
+{{% if ATTRIBUTE == "owner" %}}
|
|
|
825e43 |
+CHATTR="chown"
|
|
|
825e43 |
+{{% else %}}
|
|
|
825e43 |
+CHATTR="chgrp"
|
|
|
825e43 |
+{{% endif %}}
|
|
|
825e43 |
|
|
|
825e43 |
-GROUP_TEST=testssg
|
|
|
825e43 |
-groupadd $GROUP_TEST
|
|
|
825e43 |
+USER=root
|
|
|
825e43 |
|
|
|
825e43 |
# setup test data
|
|
|
825e43 |
create_rsyslog_test_logs 3
|
|
|
825e43 |
|
|
|
825e43 |
# setup test log files ownership
|
|
|
825e43 |
-chgrp $GROUP_ROOT ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-chgrp $GROUP_ROOT ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
-chgrp $GROUP_TEST ${RSYSLOG_TEST_LOGS[2]}
|
|
|
825e43 |
+$CHATTR $USER ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
+$CHATTR $USER ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
+$CHATTR $USER ${RSYSLOG_TEST_LOGS[2]}
|
|
|
825e43 |
|
|
|
825e43 |
# create test configuration file
|
|
|
825e43 |
test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
825e43 |
@@ -36,7 +39,8 @@ cat << EOF > ${test_conf2}
|
|
|
825e43 |
|
|
|
825e43 |
#### RULES ####
|
|
|
825e43 |
|
|
|
825e43 |
-*.* ${RSYSLOG_TEST_LOGS[2]}
|
|
|
825e43 |
+
|
|
|
825e43 |
+*.* action(type="omfile" FileCreateMode="0640" fileOwner="root" fileGroup="root" File="${RSYSLOG_TEST_LOGS[2]}")
|
|
|
825e43 |
EOF
|
|
|
825e43 |
|
|
|
825e43 |
# create rsyslog.conf configuration file
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/include_multiline_is_root.pass.sh b/shared/templates/rsyslog_logfiles_attributes_modify/tests/include_multiline_is_root.pass.sh
|
|
|
825e43 |
similarity index 81%
|
|
|
825e43 |
rename from linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/include_multiline_is_root.pass.sh
|
|
|
825e43 |
rename to shared/templates/rsyslog_logfiles_attributes_modify/tests/include_multiline_is_root.pass.sh
|
|
|
825e43 |
index d68cc2e67d..78b105abf3 100755
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/include_multiline_is_root.pass.sh
|
|
|
825e43 |
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/tests/include_multiline_is_root.pass.sh
|
|
|
825e43 |
@@ -6,14 +6,20 @@
|
|
|
825e43 |
|
|
|
825e43 |
source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
|
|
|
825e43 |
+{{% if ATTRIBUTE == "owner" %}}
|
|
|
825e43 |
+CHATTR="chown"
|
|
|
825e43 |
+{{% else %}}
|
|
|
825e43 |
+CHATTR="chgrp"
|
|
|
825e43 |
+{{% endif %}}
|
|
|
825e43 |
+
|
|
|
825e43 |
USER=root
|
|
|
825e43 |
|
|
|
825e43 |
# setup test data
|
|
|
825e43 |
create_rsyslog_test_logs 2
|
|
|
825e43 |
|
|
|
825e43 |
# setup test log files ownership
|
|
|
825e43 |
-chown $USER ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
-chown $USER ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
+$CHATTR $USER ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
+$CHATTR $USER ${RSYSLOG_TEST_LOGS[1]}
|
|
|
825e43 |
|
|
|
825e43 |
# create test configuration file
|
|
|
825e43 |
test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/is_other.fail.sh b/shared/templates/rsyslog_logfiles_attributes_modify/tests/is_other.fail.sh
|
|
|
825e43 |
similarity index 70%
|
|
|
825e43 |
rename from linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/is_other.fail.sh
|
|
|
825e43 |
rename to shared/templates/rsyslog_logfiles_attributes_modify/tests/is_other.fail.sh
|
|
|
825e43 |
index 7edbb17ea1..1afe20823c 100755
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/is_other.fail.sh
|
|
|
825e43 |
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/tests/is_other.fail.sh
|
|
|
825e43 |
@@ -5,15 +5,23 @@
|
|
|
825e43 |
|
|
|
825e43 |
source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
|
|
|
825e43 |
+{{% if ATTRIBUTE == "owner" %}}
|
|
|
825e43 |
+ADDCOMMAND="useradd"
|
|
|
825e43 |
+CHATTR="chown"
|
|
|
825e43 |
+{{% else %}}
|
|
|
825e43 |
+ADDCOMMAND="groupadd"
|
|
|
825e43 |
+CHATTR="chgrp"
|
|
|
825e43 |
+{{% endif %}}
|
|
|
825e43 |
+
|
|
|
825e43 |
USER=testssg
|
|
|
825e43 |
|
|
|
825e43 |
-useradd $USER
|
|
|
825e43 |
+$ADDCOMMAND $USER
|
|
|
825e43 |
|
|
|
825e43 |
# setup test data
|
|
|
825e43 |
create_rsyslog_test_logs 1
|
|
|
825e43 |
|
|
|
825e43 |
# setup test log file ownership
|
|
|
825e43 |
-chown $USER ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
+$CHATTR $USER ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
|
|
|
825e43 |
# add rule with non-root user owned log file
|
|
|
825e43 |
cat << EOF > $RSYSLOG_CONF
|
|
|
825e43 |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/is_root.pass.sh b/shared/templates/rsyslog_logfiles_attributes_modify/tests/is_root.pass.sh
|
|
|
825e43 |
similarity index 77%
|
|
|
825e43 |
rename from linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/is_root.pass.sh
|
|
|
825e43 |
rename to shared/templates/rsyslog_logfiles_attributes_modify/tests/is_root.pass.sh
|
|
|
825e43 |
index e0e518bc50..afce21fa27 100755
|
|
|
825e43 |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/tests/is_root.pass.sh
|
|
|
825e43 |
+++ b/shared/templates/rsyslog_logfiles_attributes_modify/tests/is_root.pass.sh
|
|
|
825e43 |
@@ -5,13 +5,19 @@
|
|
|
825e43 |
|
|
|
825e43 |
source $SHARED/rsyslog_log_utils.sh
|
|
|
825e43 |
|
|
|
825e43 |
+{{% if ATTRIBUTE == "owner" %}}
|
|
|
825e43 |
+CHATTR="chown"
|
|
|
825e43 |
+{{% else %}}
|
|
|
825e43 |
+CHATTR="chgrp"
|
|
|
825e43 |
+{{% endif %}}
|
|
|
825e43 |
+
|
|
|
825e43 |
USER=root
|
|
|
825e43 |
|
|
|
825e43 |
# setup test data
|
|
|
825e43 |
create_rsyslog_test_logs 1
|
|
|
825e43 |
|
|
|
825e43 |
# setup test log file ownership
|
|
|
825e43 |
-chown $USER ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
+$CHATTR $USER ${RSYSLOG_TEST_LOGS[0]}
|
|
|
825e43 |
|
|
|
825e43 |
# add rule with root user owned log file
|
|
|
825e43 |
cat << EOF > $RSYSLOG_CONF
|
|
|
825e43 |
--
|
|
|
825e43 |
2.39.1
|
|
|
825e43 |
|