-
Notifications
You must be signed in to change notification settings - Fork 705
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #392 from dev-sec/tally
restructure PAM handling and update for currently supported Linux distributions
- Loading branch information
Showing
20 changed files
with
430 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
- name: download pam-tester | ||
get_url: | ||
url: https://github.com/schurzi/pam-tester/releases/download/latest/pam-tester | ||
dest: /bin/pam-tester | ||
mode: 0555 | ||
|
||
- name: set password for test | ||
set_fact: | ||
test_pw: "myTest!pw" | ||
|
||
- name: set locale for test | ||
set_fact: | ||
locale: "en_US.UTF-8" | ||
when: | ||
- ansible_facts.os_family == 'RedHat' | ||
- ansible_facts.distribution_major_version < '8' | ||
|
||
- name: create testuser | ||
user: | ||
name: testuser | ||
password: "{{ test_pw | password_hash('sha512') }}" | ||
|
||
- name: check successfull login with correct password | ||
shell: | ||
cmd: "pam-tester --user testuser --password {{ test_pw }}" | ||
environment: | ||
TMPDIR: /var/tmp | ||
LC_ALL: "{{ locale | default('C.UTF-8') }}" | ||
LANG: "{{ locale | default('C.UTF-8') }}" | ||
|
||
- name: check unsuccessfull login with incorrect password | ||
shell: | ||
cmd: "pam-tester --user testuser --password {{ test_pw }}fail --expectfail" | ||
environment: | ||
TMPDIR: /var/tmp | ||
LC_ALL: "{{ locale | default('C.UTF-8') }}" | ||
LANG: "{{ locale | default('C.UTF-8') }}" | ||
with_sequence: count=6 | ||
|
||
- name: check unsuccessfull login, with correct password (lockout) | ||
shell: | ||
cmd: "pam-tester --user testuser --password {{ test_pw }} --expectfail" | ||
environment: | ||
TMPDIR: /var/tmp | ||
LC_ALL: "{{ locale | default('C.UTF-8') }}" | ||
LANG: "{{ locale | default('C.UTF-8') }}" | ||
|
||
- name: wait for account to unlock | ||
pause: | ||
seconds: 20 | ||
|
||
- name: check successfull login | ||
shell: | ||
cmd: "pam-tester --user testuser --password {{ test_pw }}" | ||
environment: | ||
TMPDIR: /var/tmp | ||
LC_ALL: "{{ locale | default('C.UTF-8') }}" | ||
LANG: "{{ locale | default('C.UTF-8') }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
--- | ||
- name: install the package for strong password checking | ||
apt: | ||
name: 'libpam-passwdqc' | ||
state: 'present' | ||
update_cache: 'yes' | ||
when: | ||
- os_auth_pam_passwdqc_enable | ||
|
||
- name: configure passwdqc | ||
template: | ||
src: 'usr/share/pam-configs/pam_passwdqc.j2' | ||
dest: '{{ passwdqc_path }}' | ||
mode: '0644' | ||
owner: 'root' | ||
group: 'root' | ||
when: | ||
- os_auth_pam_passwdqc_enable | ||
|
||
- name: install tally2 | ||
apt: | ||
name: 'libpam-modules' | ||
state: 'present' | ||
when: | ||
- os_auth_retries > 0 | ||
|
||
- name: manage tally on Debian stable | ||
block: | ||
- name: configure tally2 | ||
template: | ||
src: 'usr/share/pam-configs/pam_tally2.j2' | ||
dest: '{{ tally2_path }}' | ||
mode: '0644' | ||
owner: 'root' | ||
group: 'root' | ||
when: | ||
- os_auth_retries > 0 | ||
|
||
- name: delete tally2 when retries is 0 | ||
file: | ||
path: '{{ tally2_path }}' | ||
state: 'absent' | ||
when: | ||
- os_auth_retries == 0 | ||
when: | ||
- "'libpam-modules' in ansible_facts.packages" | ||
- "ansible_facts.packages['libpam-modules'][0].version is version('1.4.0', '<')" | ||
|
||
- name: manage tally/faillock on Debian unstable | ||
block: | ||
- name: delete tally2 | ||
file: | ||
path: '{{ tally2_path }}' | ||
state: 'absent' | ||
|
||
- name: create tally directory | ||
file: | ||
path: '/var/run/faillock' | ||
state: 'directory' | ||
mode: '0755' | ||
owner: 'root' | ||
group: 'root' | ||
|
||
- name: configure faillock | ||
template: | ||
src: 'etc/security/faillock.conf.j2' | ||
dest: '/etc/security/faillock.conf' | ||
mode: '0644' | ||
owner: 'root' | ||
group: 'root' | ||
|
||
- name: configure faillock pam | ||
template: | ||
src: 'usr/share/pam-configs/pam_faillock.j2' | ||
dest: '/usr/share/pam-configs/faillock' | ||
mode: '0644' | ||
owner: 'root' | ||
group: 'root' | ||
when: | ||
- os_auth_retries > 0 | ||
|
||
- name: configure faillock pam authfail | ||
template: | ||
src: 'usr/share/pam-configs/pam_faillock_authfail.j2' | ||
dest: '/usr/share/pam-configs/faillock_authfail' | ||
mode: '0644' | ||
owner: 'root' | ||
group: 'root' | ||
when: | ||
- os_auth_retries > 0 | ||
|
||
- name: delete faillock when retries is 0 | ||
file: | ||
path: '/usr/share/pam-configs/faillock' | ||
state: 'absent' | ||
when: | ||
- os_auth_retries == 0 | ||
|
||
- name: delete faillock authfail when retries is 0 | ||
file: | ||
path: '/usr/share/pam-configs/faillock_authfail' | ||
state: 'absent' | ||
when: | ||
- os_auth_retries == 0 | ||
when: | ||
- "'libpam-modules' in ansible_facts.packages" | ||
- "ansible_facts.packages['libpam-modules'][0].version is version('1.4.0', '>=')" | ||
|
||
- name: update pam on Debian systems | ||
command: 'pam-auth-update --package' | ||
environment: | ||
DEBIAN_FRONTEND: noninteractive | ||
changed_when: false | ||
|
||
- name: remove passwdqc | ||
apt: | ||
name: 'libpam-passwdqc' | ||
state: 'absent' | ||
when: | ||
- not os_auth_pam_passwdqc_enable |
Oops, something went wrong.