|
|
792d3d |
From 2d22616a6223e26662c1dc81e0389349defd716a Mon Sep 17 00:00:00 2001
|
|
|
792d3d |
From: Flos Lonicerae <lonicerae@gmail.com>
|
|
|
792d3d |
Date: Wed, 13 Apr 2022 20:06:18 +0800
|
|
|
792d3d |
Subject: [PATCH 01/15] rsyslog: Fix array creation when path has wildcard
|
|
|
792d3d |
|
|
|
792d3d |
This patch fixes the issue that the array is expanded to wildcard path instead of its elements.
|
|
|
792d3d |
A simple test case as follows:
|
|
|
792d3d |
|
|
|
792d3d |
/etc/rsyslog.conf
|
|
|
792d3d |
include(file="/etc/rsyslog.d/*.conf" mode="optional")
|
|
|
792d3d |
|
|
|
792d3d |
/etc/rsyslog.d/custom1.conf
|
|
|
792d3d |
local1.* /tmp/local1.out
|
|
|
792d3d |
|
|
|
792d3d |
/etc/rsyslog.d/custom2.conf
|
|
|
792d3d |
local2.* /tmp/local2.out
|
|
|
792d3d |
---
|
|
|
792d3d |
.../rsyslog_files_permissions/bash/shared.sh | 4 ++--
|
|
|
792d3d |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
792d3d |
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
index b794ea8db31..02b0c36d899 100644
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
@@ -5,8 +5,8 @@
|
|
|
792d3d |
RSYSLOG_ETC_CONFIG="/etc/rsyslog.conf"
|
|
|
792d3d |
# * And also the log file paths listed after rsyslog's $IncludeConfig directive
|
|
|
792d3d |
# (store the result into array for the case there's shell glob used as value of IncludeConfig)
|
|
|
792d3d |
-readarray -t RSYSLOG_INCLUDE_CONFIG < <(grep -e "\$IncludeConfig[[:space:]]\+[^[:space:];]\+" /etc/rsyslog.conf | cut -d ' ' -f 2)
|
|
|
792d3d |
-readarray -t RSYSLOG_INCLUDE < <(awk '/)/{f=0} /include\(/{f=1} f{nf=gensub("^(include\\(|\\s*)file=\"(\\S+)\".*","\\2",1); if($0!=nf){print nf}}' /etc/rsyslog.conf)
|
|
|
792d3d |
+readarray -t RSYSLOG_INCLUDE_CONFIG < <(printf '%s\n' $(grep -e "\$IncludeConfig[[:space:]]\+[^[:space:];]\+" /etc/rsyslog.conf | cut -d ' ' -f 2))
|
|
|
792d3d |
+readarray -t RSYSLOG_INCLUDE < <(printf '%s\n' $(awk '/)/{f=0} /include\(/{f=1} f{nf=gensub("^(include\\(|\\s*)file=\"(\\S+)\".*","\\2",1); if($0!=nf){print nf}}' /etc/rsyslog.conf))
|
|
|
792d3d |
|
|
|
792d3d |
# Declare an array to hold the final list of different log file paths
|
|
|
792d3d |
declare -a LOG_FILE_PATHS
|
|
|
792d3d |
|
|
|
792d3d |
From 37a57668e98ba613d850e4c4ec4363dc7687d06d Mon Sep 17 00:00:00 2001
|
|
|
792d3d |
From: Flos Lonicerae <lonicerae@gmail.com>
|
|
|
792d3d |
Date: Thu, 14 Apr 2022 15:58:04 +0800
|
|
|
792d3d |
Subject: [PATCH 02/15] A better fix.
|
|
|
792d3d |
|
|
|
792d3d |
* Should also fixed the CI failure.
|
|
|
792d3d |
---
|
|
|
792d3d |
.../rsyslog_files_permissions/bash/shared.sh | 6 ++++--
|
|
|
792d3d |
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
|
792d3d |
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
index 02b0c36d899..1aebb8f9da5 100644
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
@@ -5,8 +5,10 @@
|
|
|
792d3d |
RSYSLOG_ETC_CONFIG="/etc/rsyslog.conf"
|
|
|
792d3d |
# * And also the log file paths listed after rsyslog's $IncludeConfig directive
|
|
|
792d3d |
# (store the result into array for the case there's shell glob used as value of IncludeConfig)
|
|
|
792d3d |
-readarray -t RSYSLOG_INCLUDE_CONFIG < <(printf '%s\n' $(grep -e "\$IncludeConfig[[:space:]]\+[^[:space:];]\+" /etc/rsyslog.conf | cut -d ' ' -f 2))
|
|
|
792d3d |
-readarray -t RSYSLOG_INCLUDE < <(printf '%s\n' $(awk '/)/{f=0} /include\(/{f=1} f{nf=gensub("^(include\\(|\\s*)file=\"(\\S+)\".*","\\2",1); if($0!=nf){print nf}}' /etc/rsyslog.conf))
|
|
|
792d3d |
+readarray -t OLD_INC < <(grep -e "\$IncludeConfig[[:space:]]\+[^[:space:];]\+" /etc/rsyslog.conf | cut -d ' ' -f 2)
|
|
|
792d3d |
+readarray -t RSYSLOG_INCLUDE_CONFIG < <(for INCPATH in "${OLD_INC[@]}"; do eval printf '%s\\n' "${INCPATH}"; done)
|
|
|
792d3d |
+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)
|
|
|
792d3d |
+readarray -t RSYSLOG_INCLUDE < <(for INCPATH in "${NEW_INC[@]}"; do eval printf '%s\\n' "${INCPATH}"; done)
|
|
|
792d3d |
|
|
|
792d3d |
# Declare an array to hold the final list of different log file paths
|
|
|
792d3d |
declare -a LOG_FILE_PATHS
|
|
|
792d3d |
|
|
|
792d3d |
From 5135fb64fb773400234c740a3feeac206ac7f42a Mon Sep 17 00:00:00 2001
|
|
|
792d3d |
From: Flos Lonicerae <lonicerae@gmail.com>
|
|
|
792d3d |
Date: Fri, 15 Apr 2022 10:47:37 +0800
|
|
|
792d3d |
Subject: [PATCH 03/15] Add test for wildcard paths used in rsyslog
|
|
|
792d3d |
|
|
|
792d3d |
---
|
|
|
792d3d |
.../include_config_syntax_perms_0600.pass.sh | 56 ++++++++++++++++++
|
|
|
792d3d |
.../include_config_syntax_perms_0601.fail.sh | 57 +++++++++++++++++++
|
|
|
792d3d |
2 files changed, 113 insertions(+)
|
|
|
792d3d |
create mode 100755 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh
|
|
|
792d3d |
create mode 100755 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh
|
|
|
792d3d |
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh
|
|
|
792d3d |
new file mode 100755
|
|
|
792d3d |
index 00000000000..7cb09128d78
|
|
|
792d3d |
--- /dev/null
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh
|
|
|
792d3d |
@@ -0,0 +1,56 @@
|
|
|
792d3d |
+#!/bin/bash
|
|
|
792d3d |
+# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_sle
|
|
|
792d3d |
+
|
|
|
792d3d |
+# Check rsyslog.conf with log file permissions 0600 from rules and
|
|
|
792d3d |
+# log file permissions 0600 from $IncludeConfig passes.
|
|
|
792d3d |
+
|
|
|
792d3d |
+source $SHARED/rsyslog_log_utils.sh
|
|
|
792d3d |
+
|
|
|
792d3d |
+PERMS=0600
|
|
|
792d3d |
+
|
|
|
792d3d |
+# setup test data
|
|
|
792d3d |
+create_rsyslog_test_logs 3
|
|
|
792d3d |
+
|
|
|
792d3d |
+# setup test log files and permissions
|
|
|
792d3d |
+chmod $PERMS ${RSYSLOG_TEST_LOGS[0]}
|
|
|
792d3d |
+chmod $PERMS ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
+chmod $PERMS ${RSYSLOG_TEST_LOGS[2]}
|
|
|
792d3d |
+
|
|
|
792d3d |
+# create test configuration file
|
|
|
792d3d |
+conf_subdir=${RSYSLOG_TEST_DIR}/subdir
|
|
|
792d3d |
+mkdir ${conf_subdir}
|
|
|
792d3d |
+test_subdir_conf=${conf_subdir}/test_subdir.conf
|
|
|
792d3d |
+test_conf=${RSYSLOG_TEST_DIR}/test.conf
|
|
|
792d3d |
+cat << EOF > ${test_subdir_conf}
|
|
|
792d3d |
+# rsyslog configuration file
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### RULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[2]}
|
|
|
792d3d |
+EOF
|
|
|
792d3d |
+
|
|
|
792d3d |
+cat << EOF > ${test_conf}
|
|
|
792d3d |
+# rsyslog configuration file
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### RULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
+EOF
|
|
|
792d3d |
+
|
|
|
792d3d |
+# create rsyslog.conf configuration file
|
|
|
792d3d |
+cat << EOF > $RSYSLOG_CONF
|
|
|
792d3d |
+# rsyslog configuration file
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### RULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[0]}
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### MODULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+include(file="${RSYSLOG_TEST_DIR}/*/*.conf" mode="optional")
|
|
|
792d3d |
+include(file="${RSYSLOG_TEST_DIR}/*.conf" mode="optional")
|
|
|
792d3d |
+
|
|
|
792d3d |
+\$IncludeConfig ${RSYSLOG_TEST_DIR}/*/*.conf
|
|
|
792d3d |
+\$IncludeConfig ${RSYSLOG_TEST_DIR}/*.conf
|
|
|
792d3d |
+
|
|
|
792d3d |
+EOF
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh
|
|
|
792d3d |
new file mode 100755
|
|
|
792d3d |
index 00000000000..942eaf086a1
|
|
|
792d3d |
--- /dev/null
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh
|
|
|
792d3d |
@@ -0,0 +1,57 @@
|
|
|
792d3d |
+#!/bin/bash
|
|
|
792d3d |
+# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol
|
|
|
792d3d |
+
|
|
|
792d3d |
+# Check rsyslog.conf with log file permissions 0600 from rules and
|
|
|
792d3d |
+# log file permissions 0601 from $IncludeConfig fails.
|
|
|
792d3d |
+
|
|
|
792d3d |
+source $SHARED/rsyslog_log_utils.sh
|
|
|
792d3d |
+
|
|
|
792d3d |
+PERMS_PASS=0600
|
|
|
792d3d |
+PERMS_FAIL=0601
|
|
|
792d3d |
+
|
|
|
792d3d |
+# setup test data
|
|
|
792d3d |
+create_rsyslog_test_logs 3
|
|
|
792d3d |
+
|
|
|
792d3d |
+# setup test log files and permissions
|
|
|
792d3d |
+chmod $PERMS_PASS ${RSYSLOG_TEST_LOGS[0]}
|
|
|
792d3d |
+chmod $PERMS_FAIL ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
+chmod $PERMS_FAIL ${RSYSLOG_TEST_LOGS[2]}
|
|
|
792d3d |
+
|
|
|
792d3d |
+# create test configuration file
|
|
|
792d3d |
+conf_subdir=${RSYSLOG_TEST_DIR}/subdir
|
|
|
792d3d |
+mkdir ${conf_subdir}
|
|
|
792d3d |
+test_subdir_conf=${conf_subdir}/test_subdir.conf
|
|
|
792d3d |
+test_conf=${RSYSLOG_TEST_DIR}/test.conf
|
|
|
792d3d |
+cat << EOF > ${test_subdir_conf}
|
|
|
792d3d |
+# rsyslog configuration file
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### RULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[2]}
|
|
|
792d3d |
+EOF
|
|
|
792d3d |
+
|
|
|
792d3d |
+cat << EOF > ${test_conf}
|
|
|
792d3d |
+# rsyslog configuration file
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### RULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
+EOF
|
|
|
792d3d |
+
|
|
|
792d3d |
+# create rsyslog.conf configuration file
|
|
|
792d3d |
+cat << EOF > $RSYSLOG_CONF
|
|
|
792d3d |
+# rsyslog configuration file
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### RULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[0]}
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### MODULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+include(file="${RSYSLOG_TEST_DIR}/*/*.conf" mode="optional")
|
|
|
792d3d |
+include(file="${RSYSLOG_TEST_DIR}/*.conf" mode="optional")
|
|
|
792d3d |
+
|
|
|
792d3d |
+\$IncludeConfig ${RSYSLOG_TEST_DIR}/*/*.conf
|
|
|
792d3d |
+\$IncludeConfig ${RSYSLOG_TEST_DIR}/*.conf
|
|
|
792d3d |
+
|
|
|
792d3d |
+EOF
|
|
|
792d3d |
|
|
|
792d3d |
From 052558d8d5be3b8ce49067ab8c05ed9ea92bab0b Mon Sep 17 00:00:00 2001
|
|
|
792d3d |
From: Flos Lonicerae <lonicerae@gmail.com>
|
|
|
792d3d |
Date: Thu, 19 May 2022 01:22:19 +0800
|
|
|
792d3d |
Subject: [PATCH 04/15] The way using 'find' can be retired.
|
|
|
792d3d |
|
|
|
792d3d |
---
|
|
|
792d3d |
.../rsyslog_files_permissions/bash/shared.sh | 20 +++++--------------
|
|
|
792d3d |
1 file changed, 5 insertions(+), 15 deletions(-)
|
|
|
792d3d |
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
index 1aebb8f9da5..cece5930ee8 100644
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
@@ -13,22 +13,12 @@ readarray -t RSYSLOG_INCLUDE < <(for INCPATH in "${NEW_INC[@]}"; do eval printf
|
|
|
792d3d |
# Declare an array to hold the final list of different log file paths
|
|
|
792d3d |
declare -a LOG_FILE_PATHS
|
|
|
792d3d |
|
|
|
792d3d |
-RSYSLOG_CONFIGS=()
|
|
|
792d3d |
-RSYSLOG_CONFIGS=("${RSYSLOG_ETC_CONFIG}" "${RSYSLOG_INCLUDE_CONFIG[@]}" "${RSYSLOG_INCLUDE[@]}")
|
|
|
792d3d |
+declare -a RSYSLOG_CONFIGS
|
|
|
792d3d |
+RSYSLOG_CONFIGS+=("${RSYSLOG_ETC_CONFIG}" "${RSYSLOG_INCLUDE_CONFIG[@]}" "${RSYSLOG_INCLUDE[@]}")
|
|
|
792d3d |
|
|
|
792d3d |
-# Get full list of files to be checked
|
|
|
792d3d |
-# RSYSLOG_CONFIGS may contain globs such as
|
|
|
792d3d |
-# /etc/rsyslog.d/*.conf /etc/rsyslog.d/*.frule
|
|
|
792d3d |
-# So, loop over the entries in RSYSLOG_CONFIGS and use find to get the list of included files.
|
|
|
792d3d |
-RSYSLOG_FILES=()
|
|
|
792d3d |
-for ENTRY in "${RSYSLOG_CONFIGS[@]}"
|
|
|
792d3d |
-do
|
|
|
792d3d |
- mapfile -t FINDOUT < <(find "$(dirname "${ENTRY}")" -maxdepth 1 -name "$(basename "${ENTRY}")")
|
|
|
792d3d |
- RSYSLOG_FILES+=("${FINDOUT[@]}")
|
|
|
792d3d |
-done
|
|
|
792d3d |
-
|
|
|
792d3d |
-# Check file and fix if needed.
|
|
|
792d3d |
-for LOG_FILE in "${RSYSLOG_FILES[@]}"
|
|
|
792d3d |
+# Browse each file selected above as containing paths of log files
|
|
|
792d3d |
+# ('/etc/rsyslog.conf' and '/etc/rsyslog.d/*.conf' in the default configuration)
|
|
|
792d3d |
+for LOG_FILE in "${RSYSLOG_CONFIGS[@]}"
|
|
|
792d3d |
do
|
|
|
792d3d |
# From each of these files extract just particular log file path(s), thus:
|
|
|
792d3d |
# * Ignore lines starting with space (' '), comment ('#"), or variable syntax ('$') characters,
|
|
|
792d3d |
|
|
|
792d3d |
From 4f1d08642a74c0be7cd02815784a2c81b7b558ee Mon Sep 17 00:00:00 2001
|
|
|
792d3d |
From: Flos Lonicerae <lonicerae@gmail.com>
|
|
|
792d3d |
Date: Fri, 20 May 2022 01:30:37 +0800
|
|
|
792d3d |
Subject: [PATCH 05/15] Cover the include pattern '/etc/rsyslog.d/'
|
|
|
792d3d |
|
|
|
792d3d |
---
|
|
|
792d3d |
.../rsyslog_files_permissions/bash/shared.sh | 20 ++++++++++++++++++-
|
|
|
792d3d |
1 file changed, 19 insertions(+), 1 deletion(-)
|
|
|
792d3d |
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
index cece5930ee8..50d36d7426f 100644
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
@@ -13,12 +13,30 @@ readarray -t RSYSLOG_INCLUDE < <(for INCPATH in "${NEW_INC[@]}"; do eval printf
|
|
|
792d3d |
# Declare an array to hold the final list of different log file paths
|
|
|
792d3d |
declare -a LOG_FILE_PATHS
|
|
|
792d3d |
|
|
|
792d3d |
+# Array to hold all rsyslog config entries
|
|
|
792d3d |
declare -a RSYSLOG_CONFIGS
|
|
|
792d3d |
RSYSLOG_CONFIGS+=("${RSYSLOG_ETC_CONFIG}" "${RSYSLOG_INCLUDE_CONFIG[@]}" "${RSYSLOG_INCLUDE[@]}")
|
|
|
792d3d |
|
|
|
792d3d |
+# Array to hold all rsyslog config files
|
|
|
792d3d |
+declare -a RSYSLOG_CONFIG_FILES
|
|
|
792d3d |
+for ENTRY in "${RSYSLOG_CONFIGS[@]}"
|
|
|
792d3d |
+do
|
|
|
792d3d |
+ # If directory, need to include files recursively
|
|
|
792d3d |
+ if [ -d "${ENTRY}" ]
|
|
|
792d3d |
+ then
|
|
|
792d3d |
+ readarray -t FINDOUT < <(find "${ENTRY}" -type f -name '*.conf')
|
|
|
792d3d |
+ RSYSLOG_CONFIG_FILES+=("${FINDOUT[@]}")
|
|
|
792d3d |
+ elif [ -f "${ENTRY}" ]
|
|
|
792d3d |
+ then
|
|
|
792d3d |
+ RSYSLOG_CONFIG_FILES+=("${ENTRY}")
|
|
|
792d3d |
+ else
|
|
|
792d3d |
+ echo "Invalid include object: ${ENTRY}"
|
|
|
792d3d |
+ fi
|
|
|
792d3d |
+done
|
|
|
792d3d |
+
|
|
|
792d3d |
# Browse each file selected above as containing paths of log files
|
|
|
792d3d |
# ('/etc/rsyslog.conf' and '/etc/rsyslog.d/*.conf' in the default configuration)
|
|
|
792d3d |
-for LOG_FILE in "${RSYSLOG_CONFIGS[@]}"
|
|
|
792d3d |
+for LOG_FILE in "${RSYSLOG_CONFIG_FILES[@]}"
|
|
|
792d3d |
do
|
|
|
792d3d |
# From each of these files extract just particular log file path(s), thus:
|
|
|
792d3d |
# * Ignore lines starting with space (' '), comment ('#"), or variable syntax ('$') characters,
|
|
|
792d3d |
|
|
|
792d3d |
From d77551b64c4d67226627d0819dc30fff9433ac2b Mon Sep 17 00:00:00 2001
|
|
|
792d3d |
From: Flos Lonicerae <lonicerae@gmail.com>
|
|
|
792d3d |
Date: Fri, 20 May 2022 01:46:33 +0800
|
|
|
792d3d |
Subject: [PATCH 06/15] Update test files.
|
|
|
792d3d |
|
|
|
792d3d |
---
|
|
|
792d3d |
.../tests/include_config_syntax_perms_0600.pass.sh | 2 ++
|
|
|
792d3d |
.../tests/include_config_syntax_perms_0601.fail.sh | 2 ++
|
|
|
792d3d |
2 files changed, 4 insertions(+)
|
|
|
792d3d |
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh
|
|
|
792d3d |
index 7cb09128d78..2ddd9fcb697 100755
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh
|
|
|
792d3d |
@@ -49,8 +49,10 @@ cat << EOF > $RSYSLOG_CONF
|
|
|
792d3d |
|
|
|
792d3d |
include(file="${RSYSLOG_TEST_DIR}/*/*.conf" mode="optional")
|
|
|
792d3d |
include(file="${RSYSLOG_TEST_DIR}/*.conf" mode="optional")
|
|
|
792d3d |
+include(file="${RSYSLOG_TEST_DIR}" mode="optional")
|
|
|
792d3d |
|
|
|
792d3d |
\$IncludeConfig ${RSYSLOG_TEST_DIR}/*/*.conf
|
|
|
792d3d |
\$IncludeConfig ${RSYSLOG_TEST_DIR}/*.conf
|
|
|
792d3d |
+\$IncludeConfig ${RSYSLOG_TEST_DIR}
|
|
|
792d3d |
|
|
|
792d3d |
EOF
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh
|
|
|
792d3d |
index 942eaf086a1..73ff3332c6d 100755
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh
|
|
|
792d3d |
@@ -50,8 +50,10 @@ cat << EOF > $RSYSLOG_CONF
|
|
|
792d3d |
|
|
|
792d3d |
include(file="${RSYSLOG_TEST_DIR}/*/*.conf" mode="optional")
|
|
|
792d3d |
include(file="${RSYSLOG_TEST_DIR}/*.conf" mode="optional")
|
|
|
792d3d |
+include(file="${RSYSLOG_TEST_DIR}" mode="optional")
|
|
|
792d3d |
|
|
|
792d3d |
\$IncludeConfig ${RSYSLOG_TEST_DIR}/*/*.conf
|
|
|
792d3d |
\$IncludeConfig ${RSYSLOG_TEST_DIR}/*.conf
|
|
|
792d3d |
+\$IncludeConfig ${RSYSLOG_TEST_DIR}
|
|
|
792d3d |
|
|
|
792d3d |
EOF
|
|
|
792d3d |
|
|
|
792d3d |
From 9a97bfa1ca4c918a39a68131e5fbc46fa7b00961 Mon Sep 17 00:00:00 2001
|
|
|
792d3d |
From: Flos Lonicerae <lonicerae@gmail.com>
|
|
|
792d3d |
Date: Fri, 20 May 2022 10:03:32 +0800
|
|
|
792d3d |
Subject: [PATCH 07/15] Rsyslog says we should include all files
|
|
|
792d3d |
|
|
|
792d3d |
---
|
|
|
792d3d |
.../rsyslog_files_permissions/bash/shared.sh | 2 +-
|
|
|
792d3d |
.../include_config_syntax_perms_0600.pass.sh | 16 +++++++++++++++-
|
|
|
792d3d |
.../include_config_syntax_perms_0601.fail.sh | 16 +++++++++++++++-
|
|
|
792d3d |
3 files changed, 31 insertions(+), 3 deletions(-)
|
|
|
792d3d |
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
index 50d36d7426f..cd5014105e9 100644
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
@@ -24,7 +24,7 @@ do
|
|
|
792d3d |
# If directory, need to include files recursively
|
|
|
792d3d |
if [ -d "${ENTRY}" ]
|
|
|
792d3d |
then
|
|
|
792d3d |
- readarray -t FINDOUT < <(find "${ENTRY}" -type f -name '*.conf')
|
|
|
792d3d |
+ readarray -t FINDOUT < <(find "${ENTRY}" -type f)
|
|
|
792d3d |
RSYSLOG_CONFIG_FILES+=("${FINDOUT[@]}")
|
|
|
792d3d |
elif [ -f "${ENTRY}" ]
|
|
|
792d3d |
then
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh
|
|
|
792d3d |
index 2ddd9fcb697..755865ca522 100755
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh
|
|
|
792d3d |
@@ -9,20 +9,24 @@ source $SHARED/rsyslog_log_utils.sh
|
|
|
792d3d |
PERMS=0600
|
|
|
792d3d |
|
|
|
792d3d |
# setup test data
|
|
|
792d3d |
-create_rsyslog_test_logs 3
|
|
|
792d3d |
+create_rsyslog_test_logs 4
|
|
|
792d3d |
|
|
|
792d3d |
# setup test log files and permissions
|
|
|
792d3d |
chmod $PERMS ${RSYSLOG_TEST_LOGS[0]}
|
|
|
792d3d |
chmod $PERMS ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
chmod $PERMS ${RSYSLOG_TEST_LOGS[2]}
|
|
|
792d3d |
+chmod $PERMS ${RSYSLOG_TEST_LOGS[3]}
|
|
|
792d3d |
|
|
|
792d3d |
# create test configuration file
|
|
|
792d3d |
conf_subdir=${RSYSLOG_TEST_DIR}/subdir
|
|
|
792d3d |
mkdir ${conf_subdir}
|
|
|
792d3d |
test_subdir_conf=${conf_subdir}/test_subdir.conf
|
|
|
792d3d |
test_conf=${RSYSLOG_TEST_DIR}/test.conf
|
|
|
792d3d |
+test_bak=${RSYSLOG_TEST_DIR}/test.bak
|
|
|
792d3d |
+
|
|
|
792d3d |
cat << EOF > ${test_subdir_conf}
|
|
|
792d3d |
# rsyslog configuration file
|
|
|
792d3d |
+# test_subdir_conf
|
|
|
792d3d |
|
|
|
792d3d |
#### RULES ####
|
|
|
792d3d |
|
|
|
792d3d |
@@ -31,12 +35,22 @@ EOF
|
|
|
792d3d |
|
|
|
792d3d |
cat << EOF > ${test_conf}
|
|
|
792d3d |
# rsyslog configuration file
|
|
|
792d3d |
+# test_conf
|
|
|
792d3d |
|
|
|
792d3d |
#### RULES ####
|
|
|
792d3d |
|
|
|
792d3d |
*.* ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
EOF
|
|
|
792d3d |
|
|
|
792d3d |
+cat << EOF > ${test_bak}
|
|
|
792d3d |
+# rsyslog configuration file
|
|
|
792d3d |
+# test_bak
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### RULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[3]}
|
|
|
792d3d |
+EOF
|
|
|
792d3d |
+
|
|
|
792d3d |
# create rsyslog.conf configuration file
|
|
|
792d3d |
cat << EOF > $RSYSLOG_CONF
|
|
|
792d3d |
# rsyslog configuration file
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh
|
|
|
792d3d |
index 73ff3332c6d..063b1a0cbe5 100755
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh
|
|
|
792d3d |
@@ -10,20 +10,24 @@ PERMS_PASS=0600
|
|
|
792d3d |
PERMS_FAIL=0601
|
|
|
792d3d |
|
|
|
792d3d |
# setup test data
|
|
|
792d3d |
-create_rsyslog_test_logs 3
|
|
|
792d3d |
+create_rsyslog_test_logs 4
|
|
|
792d3d |
|
|
|
792d3d |
# setup test log files and permissions
|
|
|
792d3d |
chmod $PERMS_PASS ${RSYSLOG_TEST_LOGS[0]}
|
|
|
792d3d |
chmod $PERMS_FAIL ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
chmod $PERMS_FAIL ${RSYSLOG_TEST_LOGS[2]}
|
|
|
792d3d |
+chmod $PERMS_FAIL ${RSYSLOG_TEST_LOGS[3]}
|
|
|
792d3d |
|
|
|
792d3d |
# create test configuration file
|
|
|
792d3d |
conf_subdir=${RSYSLOG_TEST_DIR}/subdir
|
|
|
792d3d |
mkdir ${conf_subdir}
|
|
|
792d3d |
test_subdir_conf=${conf_subdir}/test_subdir.conf
|
|
|
792d3d |
test_conf=${RSYSLOG_TEST_DIR}/test.conf
|
|
|
792d3d |
+test_bak=${RSYSLOG_TEST_DIR}/test.bak
|
|
|
792d3d |
+
|
|
|
792d3d |
cat << EOF > ${test_subdir_conf}
|
|
|
792d3d |
# rsyslog configuration file
|
|
|
792d3d |
+# test_subdir_conf
|
|
|
792d3d |
|
|
|
792d3d |
#### RULES ####
|
|
|
792d3d |
|
|
|
792d3d |
@@ -32,12 +36,22 @@ EOF
|
|
|
792d3d |
|
|
|
792d3d |
cat << EOF > ${test_conf}
|
|
|
792d3d |
# rsyslog configuration file
|
|
|
792d3d |
+# test_conf
|
|
|
792d3d |
|
|
|
792d3d |
#### RULES ####
|
|
|
792d3d |
|
|
|
792d3d |
*.* ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
EOF
|
|
|
792d3d |
|
|
|
792d3d |
+cat << EOF > ${test_bak}
|
|
|
792d3d |
+# rsyslog configuration file
|
|
|
792d3d |
+# test_bak
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### RULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[3]}
|
|
|
792d3d |
+EOF
|
|
|
792d3d |
+
|
|
|
792d3d |
# create rsyslog.conf configuration file
|
|
|
792d3d |
cat << EOF > $RSYSLOG_CONF
|
|
|
792d3d |
# rsyslog configuration file
|
|
|
792d3d |
|
|
|
792d3d |
From fcfc7c126ed76488085ef35cd0fd497c272aa364 Mon Sep 17 00:00:00 2001
|
|
|
792d3d |
From: Flos Lonicerae <lonicerae@gmail.com>
|
|
|
792d3d |
Date: Sat, 21 May 2022 16:02:26 +0800
|
|
|
792d3d |
Subject: [PATCH 08/15] Match glob() function of rsyslog
|
|
|
792d3d |
|
|
|
792d3d |
---
|
|
|
792d3d |
.../rsyslog_files_permissions/bash/shared.sh | 5 ++-
|
|
|
792d3d |
.../include_config_syntax_perms_0600.pass.sh | 39 ++++++++++++-------
|
|
|
792d3d |
.../include_config_syntax_perms_0601.fail.sh | 39 ++++++++++++-------
|
|
|
792d3d |
3 files changed, 55 insertions(+), 28 deletions(-)
|
|
|
792d3d |
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
index cd5014105e9..38105bf086b 100644
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
@@ -21,10 +21,11 @@ RSYSLOG_CONFIGS+=("${RSYSLOG_ETC_CONFIG}" "${RSYSLOG_INCLUDE_CONFIG[@]}" "${RSYS
|
|
|
792d3d |
declare -a RSYSLOG_CONFIG_FILES
|
|
|
792d3d |
for ENTRY in "${RSYSLOG_CONFIGS[@]}"
|
|
|
792d3d |
do
|
|
|
792d3d |
- # If directory, need to include files recursively
|
|
|
792d3d |
+ # If directory, rsyslog will search for config files in recursively.
|
|
|
792d3d |
+ # However, files in hidden sub-directories or hidden files will be ignored.
|
|
|
792d3d |
if [ -d "${ENTRY}" ]
|
|
|
792d3d |
then
|
|
|
792d3d |
- readarray -t FINDOUT < <(find "${ENTRY}" -type f)
|
|
|
792d3d |
+ readarray -t FINDOUT < <(find "${ENTRY}" -not -path '*/.*' -type f)
|
|
|
792d3d |
RSYSLOG_CONFIG_FILES+=("${FINDOUT[@]}")
|
|
|
792d3d |
elif [ -f "${ENTRY}" ]
|
|
|
792d3d |
then
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh
|
|
|
792d3d |
index 755865ca522..a5a2f67fadc 100755
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0600.pass.sh
|
|
|
792d3d |
@@ -9,48 +9,61 @@ source $SHARED/rsyslog_log_utils.sh
|
|
|
792d3d |
PERMS=0600
|
|
|
792d3d |
|
|
|
792d3d |
# setup test data
|
|
|
792d3d |
-create_rsyslog_test_logs 4
|
|
|
792d3d |
+create_rsyslog_test_logs 5
|
|
|
792d3d |
|
|
|
792d3d |
# setup test log files and permissions
|
|
|
792d3d |
chmod $PERMS ${RSYSLOG_TEST_LOGS[0]}
|
|
|
792d3d |
chmod $PERMS ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
chmod $PERMS ${RSYSLOG_TEST_LOGS[2]}
|
|
|
792d3d |
chmod $PERMS ${RSYSLOG_TEST_LOGS[3]}
|
|
|
792d3d |
+chmod $PERMS ${RSYSLOG_TEST_LOGS[4]}
|
|
|
792d3d |
|
|
|
792d3d |
-# create test configuration file
|
|
|
792d3d |
+# create test configuration files
|
|
|
792d3d |
conf_subdir=${RSYSLOG_TEST_DIR}/subdir
|
|
|
792d3d |
+conf_hiddir=${RSYSLOG_TEST_DIR}/.hiddir
|
|
|
792d3d |
mkdir ${conf_subdir}
|
|
|
792d3d |
-test_subdir_conf=${conf_subdir}/test_subdir.conf
|
|
|
792d3d |
-test_conf=${RSYSLOG_TEST_DIR}/test.conf
|
|
|
792d3d |
-test_bak=${RSYSLOG_TEST_DIR}/test.bak
|
|
|
792d3d |
+mkdir ${conf_hiddir}
|
|
|
792d3d |
|
|
|
792d3d |
-cat << EOF > ${test_subdir_conf}
|
|
|
792d3d |
+test_conf_in_subdir=${conf_subdir}/in_subdir.conf
|
|
|
792d3d |
+test_conf_name_bak=${RSYSLOG_TEST_DIR}/name.bak
|
|
|
792d3d |
+
|
|
|
792d3d |
+test_conf_in_hiddir=${conf_hiddir}/in_hiddir.conf
|
|
|
792d3d |
+test_conf_dot_name=${RSYSLOG_TEST_DIR}/.name.conf
|
|
|
792d3d |
+
|
|
|
792d3d |
+cat << EOF > ${test_conf_in_subdir}
|
|
|
792d3d |
# rsyslog configuration file
|
|
|
792d3d |
-# test_subdir_conf
|
|
|
792d3d |
|
|
|
792d3d |
#### RULES ####
|
|
|
792d3d |
|
|
|
792d3d |
-*.* ${RSYSLOG_TEST_LOGS[2]}
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
EOF
|
|
|
792d3d |
|
|
|
792d3d |
-cat << EOF > ${test_conf}
|
|
|
792d3d |
+cat << EOF > ${test_conf_name_bak}
|
|
|
792d3d |
# rsyslog configuration file
|
|
|
792d3d |
-# test_conf
|
|
|
792d3d |
|
|
|
792d3d |
#### RULES ####
|
|
|
792d3d |
|
|
|
792d3d |
-*.* ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[2]}
|
|
|
792d3d |
EOF
|
|
|
792d3d |
|
|
|
792d3d |
-cat << EOF > ${test_bak}
|
|
|
792d3d |
+cat << EOF > ${test_conf_in_hiddir}
|
|
|
792d3d |
# rsyslog configuration file
|
|
|
792d3d |
-# test_bak
|
|
|
792d3d |
+# not used
|
|
|
792d3d |
|
|
|
792d3d |
#### RULES ####
|
|
|
792d3d |
|
|
|
792d3d |
*.* ${RSYSLOG_TEST_LOGS[3]}
|
|
|
792d3d |
EOF
|
|
|
792d3d |
|
|
|
792d3d |
+cat << EOF > ${test_conf_dot_name}
|
|
|
792d3d |
+# rsyslog configuration file
|
|
|
792d3d |
+# not used
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### RULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[4]}
|
|
|
792d3d |
+EOF
|
|
|
792d3d |
+
|
|
|
792d3d |
# create rsyslog.conf configuration file
|
|
|
792d3d |
cat << EOF > $RSYSLOG_CONF
|
|
|
792d3d |
# rsyslog configuration file
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh
|
|
|
792d3d |
index 063b1a0cbe5..a9d0adfb727 100755
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh
|
|
|
792d3d |
@@ -10,48 +10,61 @@ PERMS_PASS=0600
|
|
|
792d3d |
PERMS_FAIL=0601
|
|
|
792d3d |
|
|
|
792d3d |
# setup test data
|
|
|
792d3d |
-create_rsyslog_test_logs 4
|
|
|
792d3d |
+create_rsyslog_test_logs 5
|
|
|
792d3d |
|
|
|
792d3d |
# setup test log files and permissions
|
|
|
792d3d |
chmod $PERMS_PASS ${RSYSLOG_TEST_LOGS[0]}
|
|
|
792d3d |
chmod $PERMS_FAIL ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
chmod $PERMS_FAIL ${RSYSLOG_TEST_LOGS[2]}
|
|
|
792d3d |
chmod $PERMS_FAIL ${RSYSLOG_TEST_LOGS[3]}
|
|
|
792d3d |
+chmod $PERMS_FAIL ${RSYSLOG_TEST_LOGS[4]}
|
|
|
792d3d |
|
|
|
792d3d |
-# create test configuration file
|
|
|
792d3d |
+# create test configuration files
|
|
|
792d3d |
conf_subdir=${RSYSLOG_TEST_DIR}/subdir
|
|
|
792d3d |
+conf_hiddir=${RSYSLOG_TEST_DIR}/.hiddir
|
|
|
792d3d |
mkdir ${conf_subdir}
|
|
|
792d3d |
-test_subdir_conf=${conf_subdir}/test_subdir.conf
|
|
|
792d3d |
-test_conf=${RSYSLOG_TEST_DIR}/test.conf
|
|
|
792d3d |
-test_bak=${RSYSLOG_TEST_DIR}/test.bak
|
|
|
792d3d |
+mkdir ${conf_hiddir}
|
|
|
792d3d |
|
|
|
792d3d |
-cat << EOF > ${test_subdir_conf}
|
|
|
792d3d |
+test_conf_in_subdir=${conf_subdir}/in_subdir.conf
|
|
|
792d3d |
+test_conf_name_bak=${RSYSLOG_TEST_DIR}/name.bak
|
|
|
792d3d |
+
|
|
|
792d3d |
+test_conf_in_hiddir=${conf_hiddir}/in_hiddir.conf
|
|
|
792d3d |
+test_conf_dot_name=${RSYSLOG_TEST_DIR}/.name.conf
|
|
|
792d3d |
+
|
|
|
792d3d |
+cat << EOF > ${test_conf_in_subdir}
|
|
|
792d3d |
# rsyslog configuration file
|
|
|
792d3d |
-# test_subdir_conf
|
|
|
792d3d |
|
|
|
792d3d |
#### RULES ####
|
|
|
792d3d |
|
|
|
792d3d |
-*.* ${RSYSLOG_TEST_LOGS[2]}
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
EOF
|
|
|
792d3d |
|
|
|
792d3d |
-cat << EOF > ${test_conf}
|
|
|
792d3d |
+cat << EOF > ${test_conf_name_bak}
|
|
|
792d3d |
# rsyslog configuration file
|
|
|
792d3d |
-# test_conf
|
|
|
792d3d |
|
|
|
792d3d |
#### RULES ####
|
|
|
792d3d |
|
|
|
792d3d |
-*.* ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[2]}
|
|
|
792d3d |
EOF
|
|
|
792d3d |
|
|
|
792d3d |
-cat << EOF > ${test_bak}
|
|
|
792d3d |
+cat << EOF > ${test_conf_in_hiddir}
|
|
|
792d3d |
# rsyslog configuration file
|
|
|
792d3d |
-# test_bak
|
|
|
792d3d |
+# not used
|
|
|
792d3d |
|
|
|
792d3d |
#### RULES ####
|
|
|
792d3d |
|
|
|
792d3d |
*.* ${RSYSLOG_TEST_LOGS[3]}
|
|
|
792d3d |
EOF
|
|
|
792d3d |
|
|
|
792d3d |
+cat << EOF > ${test_conf_dot_name}
|
|
|
792d3d |
+# rsyslog configuration file
|
|
|
792d3d |
+# not used
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### RULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[4]}
|
|
|
792d3d |
+EOF
|
|
|
792d3d |
+
|
|
|
792d3d |
# create rsyslog.conf configuration file
|
|
|
792d3d |
cat << EOF > $RSYSLOG_CONF
|
|
|
792d3d |
# rsyslog configuration file
|
|
|
792d3d |
|
|
|
792d3d |
From 313094b7d5c13ba38a2d02fad544cd4665c5a17d Mon Sep 17 00:00:00 2001
|
|
|
792d3d |
From: Flos Lonicerae <lonicerae@gmail.com>
|
|
|
792d3d |
Date: Sun, 22 May 2022 21:10:16 +0800
|
|
|
792d3d |
Subject: [PATCH 09/15] Fixed incorrect parsing of rules in old code
|
|
|
792d3d |
|
|
|
792d3d |
---
|
|
|
792d3d |
.../rsyslog_files_permissions/bash/shared.sh | 2 +-
|
|
|
792d3d |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
792d3d |
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
index 38105bf086b..e1129e34c81 100644
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
@@ -54,7 +54,7 @@ do
|
|
|
792d3d |
then
|
|
|
792d3d |
NORMALIZED_CONFIG_FILE_LINES=$(sed -e "/^[#|$]/d" "${LOG_FILE}")
|
|
|
792d3d |
LINES_WITH_PATHS=$(grep '[^/]*\s\+\S*/\S\+$' <<< "${NORMALIZED_CONFIG_FILE_LINES}")
|
|
|
792d3d |
- FILTERED_PATHS=$(sed -e 's/[^\/]*[[:space:]]*\([^:;[:space:]]*\)/\1/g' <<< "${LINES_WITH_PATHS}")
|
|
|
792d3d |
+ FILTERED_PATHS=$(awk '{if(NF>=2&&($2~/^\//||$2~/^-\//)){sub(/^-\//,"/",$2);print $2}}' <<< "${LINES_WITH_PATHS}")
|
|
|
792d3d |
CLEANED_PATHS=$(sed -e "s/[\"')]//g; /\\/etc.*\.conf/d; /\\/dev\\//d" <<< "${FILTERED_PATHS}")
|
|
|
792d3d |
MATCHED_ITEMS=$(sed -e "/^$/d" <<< "${CLEANED_PATHS}")
|
|
|
792d3d |
# Since above sed command might return more than one item (delimited by newline), split the particular
|
|
|
792d3d |
|
|
|
792d3d |
From 86f655ac79d879c1f47bda7a06cc15a64e65e5fb Mon Sep 17 00:00:00 2001
|
|
|
792d3d |
From: Flos Lonicerae <lonicerae@gmail.com>
|
|
|
792d3d |
Date: Tue, 24 May 2022 00:42:17 +0800
|
|
|
792d3d |
Subject: [PATCH 10/15] Added platform.
|
|
|
792d3d |
|
|
|
792d3d |
---
|
|
|
792d3d |
.../tests/include_config_syntax_perms_0601.fail.sh | 2 +-
|
|
|
792d3d |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
792d3d |
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh
|
|
|
792d3d |
index a9d0adfb727..fe4db0a3c91 100755
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_config_syntax_perms_0601.fail.sh
|
|
|
792d3d |
@@ -1,5 +1,5 @@
|
|
|
792d3d |
#!/bin/bash
|
|
|
792d3d |
-# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol
|
|
|
792d3d |
+# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_sle
|
|
|
792d3d |
|
|
|
792d3d |
# Check rsyslog.conf with log file permissions 0600 from rules and
|
|
|
792d3d |
# log file permissions 0601 from $IncludeConfig fails.
|
|
|
792d3d |
|
|
|
792d3d |
From e71901895f29af9a34fe81938be1332691b6f64a Mon Sep 17 00:00:00 2001
|
|
|
792d3d |
From: Watson Sato <wsato@redhat.com>
|
|
|
792d3d |
Date: Wed, 10 Aug 2022 13:56:39 +0200
|
|
|
792d3d |
Subject: [PATCH 11/15] Reset the arrays before using them
|
|
|
792d3d |
|
|
|
792d3d |
When bash remediations for a profile are generated, it can happen that a
|
|
|
792d3d |
variable with same name is used for multiple remediations.
|
|
|
792d3d |
So let's reset the array before using it.
|
|
|
792d3d |
---
|
|
|
792d3d |
.../rsyslog_files_permissions/bash/shared.sh | 11 +++++++----
|
|
|
792d3d |
1 file changed, 7 insertions(+), 4 deletions(-)
|
|
|
792d3d |
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
index e1129e34c81..d1856ffbe7b 100644
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
|
|
|
792d3d |
@@ -14,11 +14,14 @@ readarray -t RSYSLOG_INCLUDE < <(for INCPATH in "${NEW_INC[@]}"; do eval printf
|
|
|
792d3d |
declare -a LOG_FILE_PATHS
|
|
|
792d3d |
|
|
|
792d3d |
# Array to hold all rsyslog config entries
|
|
|
792d3d |
-declare -a RSYSLOG_CONFIGS
|
|
|
792d3d |
-RSYSLOG_CONFIGS+=("${RSYSLOG_ETC_CONFIG}" "${RSYSLOG_INCLUDE_CONFIG[@]}" "${RSYSLOG_INCLUDE[@]}")
|
|
|
792d3d |
+RSYSLOG_CONFIGS=()
|
|
|
792d3d |
+RSYSLOG_CONFIGS=("${RSYSLOG_ETC_CONFIG}" "${RSYSLOG_INCLUDE_CONFIG[@]}" "${RSYSLOG_INCLUDE[@]}")
|
|
|
792d3d |
|
|
|
792d3d |
-# Array to hold all rsyslog config files
|
|
|
792d3d |
-declare -a RSYSLOG_CONFIG_FILES
|
|
|
792d3d |
+# Get full list of files to be checked
|
|
|
792d3d |
+# RSYSLOG_CONFIGS may contain globs such as
|
|
|
792d3d |
+# /etc/rsyslog.d/*.conf /etc/rsyslog.d/*.frule
|
|
|
792d3d |
+# So, loop over the entries in RSYSLOG_CONFIGS and use find to get the list of included files.
|
|
|
792d3d |
+RSYSLOG_CONFIG_FILES=()
|
|
|
792d3d |
for ENTRY in "${RSYSLOG_CONFIGS[@]}"
|
|
|
792d3d |
do
|
|
|
792d3d |
# If directory, rsyslog will search for config files in recursively.
|
|
|
792d3d |
|
|
|
792d3d |
From 525dce106bf8d054c83e8d79acbb92cc16224e4c Mon Sep 17 00:00:00 2001
|
|
|
792d3d |
From: Watson Sato <wsato@redhat.com>
|
|
|
792d3d |
Date: Wed, 10 Aug 2022 14:55:37 +0200
|
|
|
792d3d |
Subject: [PATCH 12/15] Don't parse hidden config files for Includes
|
|
|
792d3d |
|
|
|
792d3d |
Let's follow rsyslog behavior and not capture process hidden config
|
|
|
792d3d |
files for includes.
|
|
|
792d3d |
---
|
|
|
792d3d |
.../rsyslog_files_permissions/oval/shared.xml | 9 ++++
|
|
|
792d3d |
...00_IncludeConfig_perms_0601_hidden.pass.sh | 53 +++++++++++++++++++
|
|
|
792d3d |
2 files changed, 62 insertions(+)
|
|
|
792d3d |
create mode 100644 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_perms_0600_IncludeConfig_perms_0601_hidden.pass.sh
|
|
|
792d3d |
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/oval/shared.xml b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/oval/shared.xml
|
|
|
792d3d |
index a04e6fd8900..d13177216c3 100644
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/oval/shared.xml
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/oval/shared.xml
|
|
|
792d3d |
@@ -17,8 +17,17 @@
|
|
|
792d3d |
<ind:filepath>/etc/rsyslog.conf</ind:filepath>
|
|
|
792d3d |
<ind:pattern operation="pattern match">^(?:include\([\n\s]*file="([^\s;]+)".*|\$IncludeConfig[\s]+([^\s;]+))$</ind:pattern>
|
|
|
792d3d |
<ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
|
|
|
792d3d |
+ <filter action="exclude">state_permissions_ignore_hidden_paths</filter>
|
|
|
792d3d |
</ind:textfilecontent54_object>
|
|
|
792d3d |
|
|
|
792d3d |
+ <ind:textfilecontent54_state id="state_permissions_ignore_hidden_paths" comment="ignore hidden conf files" version="1">
|
|
|
792d3d |
+
|
|
|
792d3d |
+ include() or $IncludeConfig that point to hidden dirs or files.
|
|
|
792d3d |
+ Rsyslog ignores these conf files, so we should ignore them too.
|
|
|
792d3d |
+ -->
|
|
|
792d3d |
+ <ind:subexpression operation="pattern match">^.*\/\..*$</ind:subexpression>
|
|
|
792d3d |
+ </ind:textfilecontent54_state>
|
|
|
792d3d |
+
|
|
|
792d3d |
|
|
|
792d3d |
<local_variable id="var_rfp_include_config_regex" datatype="string" version="1" comment="$IncludeConfig value converted to regex">
|
|
|
792d3d |
<unique>
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_perms_0600_IncludeConfig_perms_0601_hidden.pass.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_perms_0600_IncludeConfig_perms_0601_hidden.pass.sh
|
|
|
792d3d |
new file mode 100644
|
|
|
792d3d |
index 00000000000..9b0185c6b2f
|
|
|
792d3d |
--- /dev/null
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_perms_0600_IncludeConfig_perms_0601_hidden.pass.sh
|
|
|
792d3d |
@@ -0,0 +1,53 @@
|
|
|
792d3d |
+#!/bin/bash
|
|
|
792d3d |
+# platform = Red Hat Enterprise Linux 8,multi_platform_fedora,Oracle Linux 8
|
|
|
792d3d |
+
|
|
|
792d3d |
+# Check rsyslog.conf with log file permisssions 0600 from rules and
|
|
|
792d3d |
+# log file permissions 0601 from include() fails.
|
|
|
792d3d |
+
|
|
|
792d3d |
+source $SHARED/rsyslog_log_utils.sh
|
|
|
792d3d |
+
|
|
|
792d3d |
+PERMS_PASS=0600
|
|
|
792d3d |
+PERMS_FAIL=0601
|
|
|
792d3d |
+
|
|
|
792d3d |
+# setup test data
|
|
|
792d3d |
+create_rsyslog_test_logs 3
|
|
|
792d3d |
+
|
|
|
792d3d |
+# setup test log files and permissions
|
|
|
792d3d |
+chmod $PERMS_PASS ${RSYSLOG_TEST_LOGS[0]}
|
|
|
792d3d |
+chmod $PERMS_PASS ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
+chmod $PERMS_FAIL ${RSYSLOG_TEST_LOGS[2]}
|
|
|
792d3d |
+
|
|
|
792d3d |
+# create test configuration file
|
|
|
792d3d |
+test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
792d3d |
+cat << EOF > ${test_conf}
|
|
|
792d3d |
+# rsyslog configuration file
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### RULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
+EOF
|
|
|
792d3d |
+
|
|
|
792d3d |
+# create hidden test2 configuration file
|
|
|
792d3d |
+test_conf2=${RSYSLOG_TEST_DIR}/.test2.conf
|
|
|
792d3d |
+cat << EOF > ${test_conf2}
|
|
|
792d3d |
+# rsyslog configuration file
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### RULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[2]}
|
|
|
792d3d |
+EOF
|
|
|
792d3d |
+
|
|
|
792d3d |
+# create rsyslog.conf configuration file
|
|
|
792d3d |
+cat << EOF > $RSYSLOG_CONF
|
|
|
792d3d |
+# rsyslog configuration file
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### RULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[0]}
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### MODULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+include(file="${test_conf}")
|
|
|
792d3d |
+
|
|
|
792d3d |
+\$IncludeConfig ${test_conf2}
|
|
|
792d3d |
+EOF
|
|
|
792d3d |
|
|
|
792d3d |
From d872c4a2cfcd3331b7aae954aacf3d0d481d1582 Mon Sep 17 00:00:00 2001
|
|
|
792d3d |
From: Watson Sato <wsato@redhat.com>
|
|
|
792d3d |
Date: Wed, 10 Aug 2022 15:49:11 +0200
|
|
|
792d3d |
Subject: [PATCH 13/15] Add test for for missing rsyslog included files
|
|
|
792d3d |
|
|
|
792d3d |
The rsyslog conf file may include other config files.
|
|
|
792d3d |
If the included missing files are missing rsyslog will generate an
|
|
|
792d3d |
error, but will still continue working.
|
|
|
792d3d |
https://www.rsyslog.com/doc/master/rainerscript/include.html#include-a-required-file
|
|
|
792d3d |
|
|
|
792d3d |
There is not a good way of ensuring that all files defined in a list of paths exist.
|
|
|
792d3d |
---
|
|
|
792d3d |
...0_IncludeConfig_perms_0601_missing.pass.sh | 45 +++++++++++++++++++
|
|
|
792d3d |
1 file changed, 45 insertions(+)
|
|
|
792d3d |
create mode 100644 linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_perms_0600_IncludeConfig_perms_0601_missing.pass.sh
|
|
|
792d3d |
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_perms_0600_IncludeConfig_perms_0601_missing.pass.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_perms_0600_IncludeConfig_perms_0601_missing.pass.sh
|
|
|
792d3d |
new file mode 100644
|
|
|
792d3d |
index 00000000000..b929f2a94ab
|
|
|
792d3d |
--- /dev/null
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/tests/include_perms_0600_IncludeConfig_perms_0601_missing.pass.sh
|
|
|
792d3d |
@@ -0,0 +1,45 @@
|
|
|
792d3d |
+#!/bin/bash
|
|
|
792d3d |
+# platform = Red Hat Enterprise Linux 8,multi_platform_fedora,Oracle Linux 8
|
|
|
792d3d |
+
|
|
|
792d3d |
+# Check rsyslog.conf with log file permisssions 0600 from rules and
|
|
|
792d3d |
+# log file permissions 0601 from include() fails.
|
|
|
792d3d |
+
|
|
|
792d3d |
+source $SHARED/rsyslog_log_utils.sh
|
|
|
792d3d |
+
|
|
|
792d3d |
+PERMS_PASS=0600
|
|
|
792d3d |
+PERMS_FAIL=0601
|
|
|
792d3d |
+
|
|
|
792d3d |
+# setup test data
|
|
|
792d3d |
+create_rsyslog_test_logs 3
|
|
|
792d3d |
+
|
|
|
792d3d |
+# setup test log files and permissions
|
|
|
792d3d |
+chmod $PERMS_PASS ${RSYSLOG_TEST_LOGS[0]}
|
|
|
792d3d |
+chmod $PERMS_PASS ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
+chmod $PERMS_FAIL ${RSYSLOG_TEST_LOGS[2]}
|
|
|
792d3d |
+
|
|
|
792d3d |
+# create test configuration file
|
|
|
792d3d |
+test_conf=${RSYSLOG_TEST_DIR}/test1.conf
|
|
|
792d3d |
+cat << EOF > ${test_conf}
|
|
|
792d3d |
+# rsyslog configuration file
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### RULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[1]}
|
|
|
792d3d |
+EOF
|
|
|
792d3d |
+
|
|
|
792d3d |
+# Skip creation test2 configuration file
|
|
|
792d3d |
+
|
|
|
792d3d |
+# create rsyslog.conf configuration file
|
|
|
792d3d |
+cat << EOF > $RSYSLOG_CONF
|
|
|
792d3d |
+# rsyslog configuration file
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### RULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+*.* ${RSYSLOG_TEST_LOGS[0]}
|
|
|
792d3d |
+
|
|
|
792d3d |
+#### MODULES ####
|
|
|
792d3d |
+
|
|
|
792d3d |
+include(file="${test_conf}")
|
|
|
792d3d |
+
|
|
|
792d3d |
+\$IncludeConfig ${test_conf2}
|
|
|
792d3d |
+EOF
|
|
|
792d3d |
|
|
|
792d3d |
From cf9eaf6e55405248731cb08268bcba6a58a93486 Mon Sep 17 00:00:00 2001
|
|
|
792d3d |
From: Watson Sato <wsato@redhat.com>
|
|
|
792d3d |
Date: Wed, 10 Aug 2022 21:47:18 +0200
|
|
|
792d3d |
Subject: [PATCH 14/15] Align Ansible remediation with Bash
|
|
|
792d3d |
|
|
|
792d3d |
The remediation now expands the glob expressions and doesn't collect
|
|
|
792d3d |
hidden files or directories to check for their permissions.
|
|
|
792d3d |
---
|
|
|
792d3d |
.../rsyslog_files_permissions/ansible/shared.yml | 15 +++++++++++----
|
|
|
792d3d |
1 file changed, 11 insertions(+), 4 deletions(-)
|
|
|
792d3d |
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/ansible/shared.yml b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/ansible/shared.yml
|
|
|
792d3d |
index 635b72f7352..c558bf46c71 100644
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/ansible/shared.yml
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/ansible/shared.yml
|
|
|
792d3d |
@@ -19,19 +19,26 @@
|
|
|
792d3d |
shell: |
|
|
|
792d3d |
set -o pipefail
|
|
|
792d3d |
grep -e '$IncludeConfig' {{ rsyslog_etc_config }} | cut -d ' ' -f 2 || true
|
|
|
792d3d |
- register: include_config_output
|
|
|
792d3d |
+ register: rsyslog_old_inc
|
|
|
792d3d |
changed_when: False
|
|
|
792d3d |
|
|
|
792d3d |
- name: "Get include files directives"
|
|
|
792d3d |
shell: |
|
|
|
792d3d |
set -o pipefail
|
|
|
792d3d |
grep -oP '^\s*include\s*\(\s*file.*' {{ rsyslog_etc_config }} |cut -d"\"" -f 2 || true
|
|
|
792d3d |
- register: include_files_output
|
|
|
792d3d |
+ register: rsyslog_new_inc
|
|
|
792d3d |
changed_when: False
|
|
|
792d3d |
|
|
|
792d3d |
+- name: "Expand glob expressions"
|
|
|
792d3d |
+ shell: |
|
|
|
792d3d |
+ set -o pipefail
|
|
|
792d3d |
+ eval printf '%s\\n' {{ item }}
|
|
|
792d3d |
+ register: include_config_output
|
|
|
792d3d |
+ loop: "{{ rsyslog_old_inc.stdout_lines + rsyslog_new_inc.stdout_lines }}"
|
|
|
792d3d |
+
|
|
|
792d3d |
- name: "List all config files"
|
|
|
792d3d |
- shell: find "$(dirname "{{ item }}" )" -maxdepth 1 -name "$(basename "{{ item }}")"
|
|
|
792d3d |
- loop: "{{ include_config_output.stdout_lines + include_files_output.stdout_lines }}"
|
|
|
792d3d |
+ shell: find {{ item }} -not -path "*/.*" -type f
|
|
|
792d3d |
+ loop: "{{ include_config_output.results|map(attribute='stdout_lines')|list|flatten }}"
|
|
|
792d3d |
register: rsyslog_config_files
|
|
|
792d3d |
changed_when: False
|
|
|
792d3d |
|
|
|
792d3d |
|
|
|
792d3d |
From 37e98ed3a86a0e56543132752c62982ff01cd3d9 Mon Sep 17 00:00:00 2001
|
|
|
792d3d |
From: Watson Sato <wsato@redhat.com>
|
|
|
792d3d |
Date: Wed, 10 Aug 2022 21:56:05 +0200
|
|
|
792d3d |
Subject: [PATCH 15/15] Ignore invalid or non existing include objects
|
|
|
792d3d |
|
|
|
792d3d |
Let's not fail the task when the find doesn't find the include object.
|
|
|
792d3d |
When the include is a glob expression that doesn't evaluate to any file
|
|
|
792d3d |
the glob itself is used in find command.
|
|
|
792d3d |
|
|
|
792d3d |
The Bash remediation prints a message for each include that is not a
|
|
|
792d3d |
file is not a directory or doesn't exist.
|
|
|
792d3d |
---
|
|
|
792d3d |
.../rsyslog_files_permissions/ansible/shared.yml | 1 +
|
|
|
792d3d |
1 file changed, 1 insertion(+)
|
|
|
792d3d |
|
|
|
792d3d |
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/ansible/shared.yml b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/ansible/shared.yml
|
|
|
792d3d |
index c558bf46c71..3a9380cf13b 100644
|
|
|
792d3d |
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/ansible/shared.yml
|
|
|
792d3d |
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/ansible/shared.yml
|
|
|
792d3d |
@@ -40,6 +40,7 @@
|
|
|
792d3d |
shell: find {{ item }} -not -path "*/.*" -type f
|
|
|
792d3d |
loop: "{{ include_config_output.results|map(attribute='stdout_lines')|list|flatten }}"
|
|
|
792d3d |
register: rsyslog_config_files
|
|
|
792d3d |
+ failed_when: False
|
|
|
792d3d |
changed_when: False
|
|
|
792d3d |
|
|
|
792d3d |
- name: "Extract log files"
|