mirror of
https://github.com/ansible-lockdown/RHEL9-CIS.git
synced 2025-12-24 22:23:06 +00:00
updated 1.4.2 thanks to @brent-bean #300
Signed-off-by: Mark Bolwell <mark.bollyuk@gmail.com>
This commit is contained in:
parent
5c919fb19d
commit
40078515fe
3 changed files with 48 additions and 4 deletions
|
|
@ -29,7 +29,8 @@
|
|||
- rule_1.4.2
|
||||
- NIST800-53R5_AC-3
|
||||
block:
|
||||
- name: "1.4.2 | PATCH | Ensure permissions on bootloader config are configured"
|
||||
- name: "1.4.2 | PATCH | Ensure permissions on bootloader config are configured | bios based system"
|
||||
when: rhel9cis_legacy_boot
|
||||
ansible.builtin.file:
|
||||
path: "/boot/grub2/{{ item.path }}"
|
||||
owner: root
|
||||
|
|
@ -39,6 +40,37 @@
|
|||
modification_time: preserve
|
||||
access_time: preserve
|
||||
loop:
|
||||
- { path: 'grub.cfg', mode: '0700' }
|
||||
- { path: 'grubenv', mode: 'go-rwx' }
|
||||
- { path: 'user.cfg', mode: 'go-rwx' }
|
||||
- { path: 'grub.cfg', mode: 'u-x,go-rwx' }
|
||||
- { path: 'grubenv', mode: 'u-x,go-rwx' }
|
||||
- { path: 'user.cfg', mode: 'u-x,go-rwx' }
|
||||
|
||||
- name: "1.4.2 | PATCH | Ensure permissions on bootloader config are configured | efi based system"
|
||||
when: not rhel9cis_legacy_boot
|
||||
vars:
|
||||
efi_mount_options: ['umask=0077','fmask=0077','uid=0','gid=0']
|
||||
block:
|
||||
- name: "1.4.2 | AUDIT | Ensure permissions on bootloader config are configured | efi based system | capture current state"
|
||||
ansible.builtin.shell: grep "^[^#;]" /etc/fstab | grep '/boot/efi' | cut -d ' ' -f4
|
||||
changed_when: false
|
||||
register: discovered_efi_fstab
|
||||
|
||||
- name: "1.4.2 | PATCH | Ensure permissions on bootloader config are configured | efi based system | Build Options"
|
||||
when: item not in discovered_efi_fstab.stdout
|
||||
ansible.builtin.set_fact:
|
||||
efi_mount_opts_addition: "{{ efi_mount_opts_addition + item + ',' }}"
|
||||
loop: "{{ efi_mount_options }}"
|
||||
|
||||
- name: "1.4.2 | PATCH | Ensure permissions on bootloader config are configured | efi based system | Add mount options"
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/fstab
|
||||
regexp: (.*/boot/efi\s*\w*\s*){{ discovered_efi_fstab.stdout }}(.*)
|
||||
line: \1{{ discovered_efi_fstab.stdout + efi_mount_opts_addition }}\2
|
||||
backrefs: true
|
||||
notify: Remount /boot/efi
|
||||
|
||||
- debug:
|
||||
msg:
|
||||
- "{{ discovered_efi_fstab.stdout }}"
|
||||
- "{{ efi_mount_opts_addition }}"
|
||||
|
||||
- pause:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue