Skip to content

Commit 8f22ce7

Browse files
authored
Feature coredump (#513)
* restructure limits-tasks * disable coredumps in tests * use notify-task for systemd-reload Signed-off-by: rndmh3ro <[email protected]> * add notify to another task Signed-off-by: rndmh3ro <[email protected]> * rm obsolete task and rename handler Signed-off-by: rndmh3ro <[email protected]>
1 parent 945d00f commit 8f22ce7

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

molecule/os_hardening/converge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
name: os_hardening
1717
vars:
1818
os_security_users_allow: change_user
19-
os_security_kernel_enable_core_dump: true
19+
os_security_kernel_enable_core_dump: false
2020
os_security_suid_sgid_remove_from_unknown: true
2121
os_auth_pam_passwdqc_enable: false
2222
os_auth_lockout_time: 15

roles/os_hardening/handlers/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@
77
cmd: 'service auditd restart' # rhel: see: https://access.redhat.com/solutions/2664811
88
warn: false # sadly 'service' module fails in that case also by using 'use: service'
99
when: molecule_yml is not defined # restarting auditd in a container does not work
10+
11+
- name: Reload systemd
12+
systemd:
13+
daemon_reload: yes

roles/os_hardening/tasks/limits.yml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
- block:
2+
- name: disable coredumps
3+
block:
34
- name: Create limits.d-directory if it does not exist | sysctl-31a, sysctl-31b
45
file:
56
path: '/etc/security/limits.d'
@@ -27,22 +28,14 @@
2728
modification_time: preserve
2829
access_time: preserve
2930

30-
when: not os_security_kernel_enable_core_dump | bool
31-
32-
- name: Remove 10.hardcore.conf config file
33-
file:
34-
path: /etc/security/limits.d/10.hardcore.conf
35-
state: absent
36-
when: os_security_kernel_enable_core_dump | bool
37-
38-
- block:
3931
- name: create coredump.conf.d-directory if it does not exist
4032
file:
4133
path: '/etc/systemd/coredump.conf.d'
4234
owner: root
4335
group: root
4436
mode: 0755
4537
state: directory
38+
when: ansible_service_mgr == "systemd"
4639

4740
- name: create custom.conf for disabling coredumps
4841
template:
@@ -51,21 +44,22 @@
5144
owner: root
5245
group: root
5346
mode: 0644
54-
55-
- name: Reload daemon
56-
systemd:
57-
daemon_reload: yes
47+
when: ansible_service_mgr == "systemd"
48+
notify: Reload systemd
5849

5950
when: not os_security_kernel_enable_core_dump | bool
6051

61-
- block:
52+
- name: enable coredumps
53+
block:
6254
- name: Remove coredump.conf.d directory with files
6355
file:
6456
path: /etc/systemd/coredump.conf.d
6557
state: absent
58+
when: ansible_service_mgr == "systemd"
59+
notify: Reload systemd
6660

67-
- name: Reload daemon
68-
systemd:
69-
daemon_reload: yes
70-
61+
- name: Remove 10.hardcore.conf config file
62+
file:
63+
path: /etc/security/limits.d/10.hardcore.conf
64+
state: absent
7165
when: os_security_kernel_enable_core_dump | bool

0 commit comments

Comments
 (0)