better output if trying to login with non-existing user

This commit is contained in:
Patrick Schleizer 2019-12-31 08:18:38 -05:00
parent b2bdeb9095
commit 5031e7cc4b
No known key found for this signature in database
GPG Key ID: CB8D50BB77BB3C48

View File

@ -1,6 +1,11 @@
#!/bin/bash
if [ "$(passwd -S "$PAM_USER" | cut -d ' ' -f 2)" = "P" ]; then
if ! passwd_output="$(passwd -S "$PAM_USER" 2>/dev/null)" ; then
echo "$0: ERROR: user \"$PAM_USER\" does not exist." >&2
exit 1
fi
if [ "$(echo "$passwd_output" | cut -d ' ' -f 2)" = "P" ]; then
true "INFO: Password not locked."
else
echo "$0: ERROR: Password for user \"$PAM_USER\" is locked." >&2