- name: XCCDF Value var_password_pam_difok # promote to variable
set_fact:
var_password_pam_difok: !!str <xccdf-1.2:sub xmlns:xccdf-1.2="http://checklists.nist.gov/xccdf/1.2" idref="xccdf_org.ssgproject.content_value_var_password_pam_difok" use="legacy"/>
tags:
- always
- name: Set control_flag fact set_fact:
control_flag: requisite
tags:
- CCE-83170-1
- DISA-STIG-SLES-12-010190
- NIST-800-53-IA-5(b)
- NIST-800-53-IA-5(v)
- cracklib_accounts_password_pam_difok
- low_complexity
- low_disruption
- medium_severity
- no_reboot_needed
- restrict_strategy
- name: Check to see if 'pam_cracklib.so' module is configured in '/etc/pam.d/common-password'
shell: |
set -o pipefail
grep -E '^\s*password\s+\S+\s+pam_cracklib.so' /etc/pam.d/common-password || true
register: check_pam_module_result
tags:
- CCE-83170-1
- DISA-STIG-SLES-12-010190
- NIST-800-53-IA-5(b)
- NIST-800-53-IA-5(v)
- cracklib_accounts_password_pam_difok
- low_complexity
- low_disruption
- medium_severity
- no_reboot_needed
- restrict_strategy
- name: Configure 'pam_cracklib.so' module in '/etc/pam.d/common-password'
lineinfile:
path: /etc/pam.d/common-password
line: password requisite pam_cracklib.so
state: present
when: check_pam_module_result.stdout is defined and '"pam_cracklib.so" not in check_pam_module_result.stdout'
tags:
- CCE-83170-1
- DISA-STIG-SLES-12-010190
- NIST-800-53-IA-5(b)
- NIST-800-53-IA-5(v)
- cracklib_accounts_password_pam_difok
- low_complexity
- low_disruption
- medium_severity
- no_reboot_needed
- restrict_strategy
- name: Ensure 'pam_cracklib.so' module has conforming control flag
lineinfile:
path: /etc/pam.d/common-password
regexp: ^(\s*password\s+)\S+(\s+pam_cracklib.so\s+.*)
line: \g<1>requisite\g<2>
backrefs: true
when: control_flag|length
tags:
- CCE-83170-1
- DISA-STIG-SLES-12-010190
- NIST-800-53-IA-5(b)
- NIST-800-53-IA-5(v)
- cracklib_accounts_password_pam_difok
- low_complexity
- low_disruption
- medium_severity
- no_reboot_needed
- restrict_strategy
- name: Ensure "pam_cracklib.so" module has argument "difok={{ var_password_pam_difok
}}"
lineinfile:
path: /etc/pam.d/common-password
regexp: ^(\s*password\s+requisite\s+pam_cracklib.so(?:\s+\S+)*\s+difok=)(?:\S+)((\s+\S+)*\s*\\*\s*)$
line: \g<1>{{ var_password_pam_difok }}\g<2>
backrefs: true
tags:
- CCE-83170-1
- DISA-STIG-SLES-12-010190
- NIST-800-53-IA-5(b)
- NIST-800-53-IA-5(v)
- cracklib_accounts_password_pam_difok
- low_complexity
- low_disruption
- medium_severity
- no_reboot_needed
- restrict_strategy
- name: Check the presence of "difok" argument in "pam_cracklib.so" module
shell: |
set -o pipefail
grep -E '^\s*password\s+requisite\s+pam_cracklib.so.*\s+difok(=|\s|\s*$)' /etc/pam.d/common-password || true
register: check_pam_module_argument_result
tags:
- CCE-83170-1
- DISA-STIG-SLES-12-010190
- NIST-800-53-IA-5(b)
- NIST-800-53-IA-5(v)
- cracklib_accounts_password_pam_difok
- low_complexity
- low_disruption
- medium_severity
- no_reboot_needed
- restrict_strategy
- name: Add "difok" argument to "pam_cracklib.so" module
lineinfile:
path: /etc/pam.d/common-password
regexp: ^(\s*password\s+requisite\s+pam_cracklib.so)((\s+\S+)*\s*(\\)*$)
line: \g<1> difok={{ var_password_pam_difok }}\g<2>
backrefs: true
when: check_pam_module_argument_result is not skipped and '"difok" not in check_pam_module_argument_result.stdout'
tags:
- CCE-83170-1
- DISA-STIG-SLES-12-010190
- NIST-800-53-IA-5(b)
- NIST-800-53-IA-5(v)
- cracklib_accounts_password_pam_difok
- low_complexity
- low_disruption
- medium_severity
- no_reboot_needed
- restrict_strategy