Blame SOURCES/scap-security-guide-0.1.58-fix_audit_file_permissions-PR_7440.patch

9be3b2
From 1dcdad51a48c17dd5dbb7eb9bbb8cef23cf00e29 Mon Sep 17 00:00:00 2001
9be3b2
From: Gabriel Becker <ggasparb@redhat.com>
9be3b2
Date: Mon, 23 Aug 2021 10:26:39 +0200
9be3b2
Subject: [PATCH] Fix remaining audit rule files permissions.
9be3b2
9be3b2
---
9be3b2
 .../audit_rules_immutable/ansible/shared.yml                 | 1 +
9be3b2
 .../audit_rules_immutable/bash/shared.sh                     | 1 +
9be3b2
 shared/templates/audit_file_contents/ansible.template        | 5 +++++
9be3b2
 shared/templates/audit_file_contents/bash.template           | 2 ++
9be3b2
 4 files changed, 9 insertions(+)
9be3b2
9be3b2
diff --git a/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_immutable/ansible/shared.yml b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_immutable/ansible/shared.yml
9be3b2
index 1cafb744cc3..736d4c333e4 100644
9be3b2
--- a/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_immutable/ansible/shared.yml
9be3b2
+++ b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_immutable/ansible/shared.yml
9be3b2
@@ -22,6 +22,7 @@
9be3b2
     path: "{{ item }}"
9be3b2
     create: True
9be3b2
     line: "-e 2"
9be3b2
+    mode: o-rwx
9be3b2
   loop:
9be3b2
     - "/etc/audit/audit.rules"
9be3b2
     - "/etc/audit/rules.d/immutable.rules"
9be3b2
diff --git a/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_immutable/bash/shared.sh b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_immutable/bash/shared.sh
9be3b2
index 29cd4a5de6f..36e0691493f 100644
9be3b2
--- a/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_immutable/bash/shared.sh
9be3b2
+++ b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_immutable/bash/shared.sh
9be3b2
@@ -20,4 +20,5 @@ do
9be3b2
 	echo '# Set the audit.rules configuration immutable per security requirements' >> $AUDIT_FILE
9be3b2
 	echo '# Reboot is required to change audit rules once this setting is applied' >> $AUDIT_FILE
9be3b2
 	echo '-e 2' >> $AUDIT_FILE
9be3b2
+	chmod o-rwx $AUDIT_FILE
9be3b2
 done
9be3b2
diff --git a/shared/templates/audit_file_contents/ansible.template b/shared/templates/audit_file_contents/ansible.template
9be3b2
index c2852745451..a262386cfbf 100644
9be3b2
--- a/shared/templates/audit_file_contents/ansible.template
9be3b2
+++ b/shared/templates/audit_file_contents/ansible.template
9be3b2
@@ -9,3 +9,8 @@
9be3b2
         contents=CONTENTS,
9be3b2
     )
9be3b2
 }}}
9be3b2
+
9be3b2
+- name: Remove any permissions from other group
9be3b2
+  file:
9be3b2
+    path: {{{ FILEPATH }}}
9be3b2
+    mode: o-rwx
9be3b2
diff --git a/shared/templates/audit_file_contents/bash.template b/shared/templates/audit_file_contents/bash.template
9be3b2
index f264be6f14d..d6277167892 100644
9be3b2
--- a/shared/templates/audit_file_contents/bash.template
9be3b2
+++ b/shared/templates/audit_file_contents/bash.template
9be3b2
@@ -11,4 +11,6 @@
9be3b2
     )
9be3b2
 }}}
9be3b2
 
9be3b2
+chmod o-rwx {{{ FILEPATH }}}
9be3b2
+
9be3b2
 augenrules --load