second commit
This commit is contained in:
48
ansible/roles/os_hardening/tasks/mounts.yml
Normal file
48
ansible/roles/os_hardening/tasks/mounts.yml
Normal file
@ -0,0 +1,48 @@
|
||||
---
|
||||
# CIS 1.1.2.x (nodev/nosuid/noexec auf /tmp, /dev/shm). Best-Effort: nur
|
||||
# wirksam, wenn diese Pfade BEREITS eigene Mountpoints sind. Ob das der Fall
|
||||
# ist, haengt vom Partitionslayout des Basis-Images ab -- siehe
|
||||
# CIS_STIG_MAPPING.md fuer den Hinweis, dass ein vollstaendig CIS-konformes
|
||||
# Partitionslayout (separate /tmp, /var, /var/log, /var/log/audit, /home)
|
||||
# eine bewusste Entscheidung bei der OS-Installation ist und nicht nachtraeglich
|
||||
# per Ansible auf ein bestehendes System aufgepraegt werden kann, ohne die
|
||||
# Platte neu zu partitionieren.
|
||||
|
||||
- name: Pruefen, ob /tmp ein eigener Mountpoint ist
|
||||
ansible.builtin.command: findmnt --noheadings --output SOURCE /tmp
|
||||
register: _tmp_mount
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: /tmp mit noexec,nosuid,nodev in /etc/fstab absichern (falls eigener Mountpoint)
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/fstab
|
||||
regexp: '^\S+\s+/tmp\s+'
|
||||
line: "{{ _tmp_mount.stdout }} /tmp tmpfs defaults,noexec,nosuid,nodev 0 0"
|
||||
backup: true
|
||||
when: os_hardening_restrict_tmp_mounts and _tmp_mount.rc == 0 and _tmp_mount.stdout != ''
|
||||
notify: remount tmp
|
||||
|
||||
- name: Pruefen, ob /dev/shm ein eigener Mountpoint ist
|
||||
ansible.builtin.command: findmnt --noheadings --output SOURCE /dev/shm
|
||||
register: _shm_mount
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: /dev/shm mit noexec,nosuid,nodev in /etc/fstab absichern (falls eigener Mountpoint)
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/fstab
|
||||
regexp: '^\S+\s+/dev/shm\s+'
|
||||
line: "{{ _shm_mount.stdout }} /dev/shm tmpfs defaults,noexec,nosuid,nodev 0 0"
|
||||
backup: true
|
||||
when: os_hardening_restrict_tmp_mounts and _shm_mount.rc == 0 and _shm_mount.stdout != ''
|
||||
notify: remount shm
|
||||
|
||||
- name: Hinweis, falls /tmp kein eigener Mountpoint ist
|
||||
ansible.builtin.debug:
|
||||
msg: >
|
||||
/tmp ist kein eigener Mountpoint auf diesem System -- noexec/nosuid/nodev
|
||||
koennen so nicht erzwungen werden. Fuer volle CIS-Konformitaet muesste
|
||||
/tmp bei der OS-Installation als eigene Partition/eigenes tmpfs angelegt
|
||||
werden (siehe CIS_STIG_MAPPING.md).
|
||||
when: os_hardening_restrict_tmp_mounts and (_tmp_mount.rc != 0 or _tmp_mount.stdout == '')
|
||||
Reference in New Issue
Block a user