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

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