florianutz / ubuntu2004_cis

Ubuntu CIS Hardening Ansible Role
MIT License
108 stars 67 forks source link

Accounts with empty password causes fatal error #24

Open rossigee opened 3 years ago

rossigee commented 3 years ago

Describe the bug

When run against a host with no root password set, exits with positive exitcode, failing the run.

TASK [florianutz.ubuntu2004_cis : PRELIM | Gather accounts with empty password fields] **********************************************************************************************************************
ok: [sg0host1]
fatal: [sg0admin3]: FAILED! => {"changed": false, "cmd": "set -o pipefail; cat /etc/shadow | awk -F: '($2 == \"\" ) {j++;print $1; } END {exit j}'", "delta": "0:00:00.015997", "end": "2021-03-19 10:21:28.579102", "msg": "non-zero return code", "rc": 1, "start": "2021-03-19 10:21:28.563105", "stderr": "", "stderr_lines": [], "stdout": "root", "stdout_lines": ["root"]}
ok: [sg0host2]
root@sg0admin3:/home/ross# set -o pipefail; cat /etc/shadow | awk -F: '($2 == "" ) {j++;print $1; } END {exit j}'
root
root@sg0admin3:/home/ross# echo $?
1

To Reproduce

Steps to reproduce the behavior:

  1. Run passwd -d <some_login> on a host.
  2. Run Ansible against it using this role.

Expected behavior

A zero exit code, allowing the role to proceed.

Software (please complete the following information):

Additional context

Workaround is passwd -l <some_login>