forked from ansible-lockdown/RHEL9-CIS
v2 improvements
Signed-off-by: Mark Bolwell <mark.bollyuk@gmail.com>
This commit is contained in:
parent
7c2a6a2a89
commit
0fc418a222
14 changed files with 542 additions and 709 deletions
|
|
@ -18,17 +18,31 @@
|
|||
register: rhel9cis_pam_nullok
|
||||
|
||||
- name: "5.3.3.4.1 | PATCH | Ensure pam_unix does not include nullok | Ensure nullok removed"
|
||||
when: rhel9cis_pam_nullok.stdout | length > 0
|
||||
when:
|
||||
- rhel9cis_pam_nullok.stdout | length > 0
|
||||
- not rhel9cis_allow_authselect_updates
|
||||
ansible.builtin.replace:
|
||||
path: "{{ item }}"
|
||||
regexp: nullok
|
||||
replace: ''
|
||||
loop: "{{ rhel9cis_pam_nullok.stdout_lines }}"
|
||||
notify: Pam_auth_update_pwunix
|
||||
|
||||
- name: "5.3.3.4.1 | PATCH | Ensure password number of changed characters is configured | Remove nullok from pam files AuthSelect"
|
||||
when:
|
||||
- rhel9cis_allow_authselect_updates
|
||||
ansible.builtin.replace:
|
||||
path: "/etc/authselect/custom/{{ rhel9cis_authselect_custom_profile_name }}/{{ item }}-auth"
|
||||
regexp: ^(\s*password\s+(requisite|required|sufficient)\s+pam_unix\.so)(.*)\snullok(.*$)
|
||||
replace: \1\2\3
|
||||
loop:
|
||||
- password
|
||||
- system
|
||||
notify: Authselect update
|
||||
|
||||
- name: "5.3.3.4.2 | PATCH | Ensure pam_unix does not include remember"
|
||||
when:
|
||||
- rhel9cis_rule_5_3_3_4_2
|
||||
- rhel9cis_disruption_high
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
|
|
@ -37,22 +51,36 @@
|
|||
- rule_5.3.3.4.2
|
||||
block:
|
||||
- name: "5.3.3.4.2 | AUDIT | Ensure pam_unix does not include remember | capture state"
|
||||
ansible.builtin.shell: grep -PH -- '^\h*^\h*[^#\n\r]+\h+pam_unix\.so\b' /etc/pam.d/common-{password,auth,account,session,session-noninteractive} | grep -Pv -- '\bremember=\d\b'
|
||||
ansible.builtin.shell: grep -PH -- '^\h*^password\h*[^#\n\r]+\h+pam_unix\.so\b' /etc/pam.d/{password,system}-auth | grep -P -- '\bremember\b'
|
||||
changed_when: false
|
||||
failed_when: rhel9cis_pam_remember.rc not in [ 0, 1 ]
|
||||
register: rhel9cis_pam_remember
|
||||
|
||||
- name: "5.3.3.4.2 | PATCH | Ensure pam_unix does not include remember | Ensure remember removed"
|
||||
when: rhel9cis_pam_remember.stdout | length > 0
|
||||
when:
|
||||
- not rhel9cis_allow_authselect_updates
|
||||
- rhel9cis_pam_remember.stdout | length > 0
|
||||
ansible.builtin.replace:
|
||||
path: "/{{ rhel9cis_pam_confd_dir }}{{ rhel9cis_pam_pwunix_file }}"
|
||||
regexp: remember=\d+
|
||||
replace: ''
|
||||
notify: Pam_auth_update_pwunix
|
||||
|
||||
- name: "5.3.3.4.2 | PATCH | Ensure pam_unix does not include remember | Remove remember from pam files AuthSelect"
|
||||
when:
|
||||
- rhel9cis_allow_authselect_updates
|
||||
ansible.builtin.replace:
|
||||
path: "/etc/authselect/custom/{{ rhel9cis_authselect_custom_profile_name }}/{{ item }}-auth"
|
||||
regexp: ^(\s*password\s+(requisite|required|sufficient)\s+pam_unix\.so)(.*)\sremember\s*=\s*=\d*(.*$)
|
||||
replace: \1\2\3
|
||||
loop:
|
||||
- password
|
||||
- system
|
||||
notify: Authselect update
|
||||
|
||||
- name: "5.3.3.4.3 | PATCH | Ensure pam_unix includes a strong password hashing algorithm"
|
||||
when:
|
||||
- rhel9cis_rule_5_3_3_4_3
|
||||
- rhel9cis_disruption_high
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
|
|
@ -68,16 +96,31 @@
|
|||
register: rhel9cis_pam_pwhash
|
||||
|
||||
- name: "5.3.3.4.3 | PATCH | Ensure pam_unix includes a strong password hashing algorithm | Ensure hash algorithm set"
|
||||
when: rhel9cis_pam_remember.stdout | length > 0
|
||||
when:
|
||||
- not rhel9cis_allow_authselect_updates
|
||||
- rhel9cis_pam_remember.stdout | length > 0
|
||||
ansible.builtin.replace:
|
||||
path: "/{{ rhel9cis_pam_confd_dir }}{{ rhel9cis_pam_pwunix_file }}"
|
||||
regexp: "(md5|bigcrypt|sha256|blowfish|gost_yescrypt|sha512|yescrypt)"
|
||||
replace: '{{ rhel9cis_passwd_hash_algo }}'
|
||||
notify: Pam_auth_update_pwunix
|
||||
|
||||
- name: "5.3.3.4.3 | PATCH | Ensure pam_unix includes a strong password hashing algorithm | Remove remember from pam files AuthSelect"
|
||||
when:
|
||||
- rhel9cis_allow_authselect_updates
|
||||
ansible.builtin.lineinfile:
|
||||
path: "/etc/authselect/custom/{{ rhel9cis_authselect_custom_profile_name }}/{{ item }}-auth"
|
||||
regexp: ^(\s*password\s+(requisite|required|sufficient)\s+pam_unix\.so)(.*)(sha512|yescrypt)(.*$)
|
||||
line: \1\2 {{ rhel9cis_passwd_hash_algo }}\4
|
||||
backrefs: true
|
||||
loop:
|
||||
- password
|
||||
- system
|
||||
notify: Authselect update
|
||||
|
||||
- name: "5.3.3.4.4 | PATCH | Ensure pam_unix includes use_authtok"
|
||||
when:
|
||||
- rhel9cis_rule_5_3_3_4_4
|
||||
- rhel9cis_disruption_high
|
||||
tags:
|
||||
- level1-server
|
||||
- level1-workstation
|
||||
|
|
@ -87,18 +130,32 @@
|
|||
- NIST800-53R5_IA-5
|
||||
block:
|
||||
- name: "5.3.3.4.4 | PATCH | Ensure pam_unix includes use_authtok | capture state"
|
||||
ansible.builtin.shell: grep -PH -- '^\h*password\h+([^#\n\r]+)\h+pam_unix\.so\h+([^#\n\r]+\h+)?use_authtok\b' /etc/pam.d/{password,system}-auth
|
||||
ansible.builtin.shell: grep -PH -- '^\h*^password\h*[^#\n\r]+\h+pam_unix\.so\b' /etc/pam.d/{password,system}-auth | grep -Pv -- '\buse_authtok\b'
|
||||
changed_when: false
|
||||
failed_when: rhel9cis_pam_authtok.rc not in [ 0, 1 ]
|
||||
register: rhel9cis_pam_authtok
|
||||
|
||||
- name: "5.3.3.4.4 | PATCH | Ensure pam_unix includes use_authtok | pam_files"
|
||||
when:
|
||||
- not rhel9cis_allow_authselect_updates
|
||||
- rhel9cis_pam_authtok is defined
|
||||
- rhel9cis_pam_authtok.stdout | length > 0
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ item }}"
|
||||
regexp: ^(\s*password\s+[success=end.*]\s+pam_unix\.so)(.*)\s+use_authtok\s*=\s*\S+(.*$)
|
||||
line: \1\2\3 use_authtok
|
||||
regexp: ^(\s*password\s+(requisite|required|sufficient)\s+pam_unix\.so)(.*)use_authtok(.*$)
|
||||
line: \1\2 use_authtok\3
|
||||
backrefs: true
|
||||
loop: "{{ rhel9cis_pam_authtok.stdout_lines }}"
|
||||
|
||||
- name: "5.3.3.4.4 | PATCH | Ensure pam_unix includes use_authtok | Add use_authtok pam files AuthSelect"
|
||||
when:
|
||||
- rhel9cis_allow_authselect_updates
|
||||
ansible.builtin.lineinfile:
|
||||
path: "/etc/authselect/custom/{{ rhel9cis_authselect_custom_profile_name }}/{{ item }}-auth"
|
||||
regexp: ^(\s*password\s+(requisite|required|sufficient)\s+pam_unix\.so)(.*)use_authtok(.*$)
|
||||
line: \1\2 use_authtok\3
|
||||
backrefs: true
|
||||
loop:
|
||||
- password
|
||||
- system
|
||||
notify: Authselect update
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue