Skip to content

Commit 0705a9c

Browse files
authored
Merge pull request #628 from Normo/add-password-warn-age-option
Set number of warning days before user password expires
2 parents 1b1b0e1 + c594a1f commit 0705a9c

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

Diff for: molecule/os_hardening/converge.yml

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
os_filesystem_whitelist: []
3030
os_yum_repo_file_whitelist: ['foo.repo']
3131
os_users_without_password_ageing: ['pw_no_ageing']
32+
os_auth_pw_warn_age: 7
3233
os_netrc_enabled: false
3334
os_ignore_users: ["shell_sys_acc"]
3435
os_ignore_home_folder_users: ["user_with_777_home"]

Diff for: molecule/os_hardening/verify_tasks/pw_ageing.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,19 @@
1414
changed_when: false
1515
register: expiry_date
1616

17-
- name: Check that the expiry date of pw_ageing is 30 days
17+
- name: Check that the expiry date of pw_ageing is 60 days
1818
ansible.builtin.assert:
1919
# this uses the date from the expire_date variable and subtracts the current date.
2020
# it should be bigger that the password_expire_min of the user "pw_no_ageing"
2121
that:
2222
- "{{ ( expiry_date.stdout | trim | to_datetime('%b %d, %Y') - ansible_date_time.date | to_datetime('%Y-%m-%d')).days }} == 60"
23+
24+
- name: Get Password Expiry warning days for pw_ageing
25+
ansible.builtin.shell: chage -l pw_ageing | grep "warning before password expires" | cut -d ":" -f 2
26+
changed_when: false
27+
register: expiry_warndays
28+
29+
- name: Check that number of days of warning before password expires is 7 days
30+
ansible.builtin.assert:
31+
that:
32+
- "expiry_warndays.stdout | trim == '7'"

Diff for: roles/os_hardening/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ We know that this is the case on Raspberry Pi.
107107
- `os_auth_pw_min_age`
108108
- Default: `7`
109109
- Description: minimum password age (before allowing any other password change).
110+
- `os_auth_pw_warn_age`
111+
- Default: `7`
112+
- Description: number of days of warning before password expires.
110113
- `os_auth_pw_remember`
111114
- Default: `5`
112115
- Description: how many used passwords are record.

Diff for: roles/os_hardening/defaults/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ os_desktop_enable: false
33
os_env_extra_user_paths: []
44
os_auth_pw_max_age: 60
55
os_auth_pw_min_age: 7 # Discourage password cycling
6+
os_auth_pw_warn_age: 7
67
os_auth_pw_remember: 5 # Specify how many used passwords are record
78
os_auth_retries: 5
89
os_auth_lockout_time: 600 # Seconds (600 = 10min)

Diff for: roles/os_hardening/templates/etc/login.defs.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ PASS_MAX_DAYS {{ os_auth_pw_max_age }}
110110
PASS_MIN_DAYS {{ os_auth_pw_min_age }}
111111

112112
# Number of days warning given before a password expires.
113-
PASS_WARN_AGE 7
113+
PASS_WARN_AGE {{ os_auth_pw_warn_age }}
114114

115115
# Min/max values for automatic uid selection in useradd
116116
UID_MIN {{ os_auth_uid_min }}

0 commit comments

Comments
 (0)