pam-info refactoring

This commit is contained in:
Patrick Schleizer 2022-11-16 01:49:45 -05:00
parent bb6b509d06
commit ae113442a1
No known key found for this signature in database
GPG Key ID: CB8D50BB77BB3C48

View File

@ -95,20 +95,27 @@ fi
# fi
# fi
## Using || true to not break read-only disk boot without ro-mode-init or grub-live.
pam_faillock_output="$(faillock --user "$PAM_USER")" || true
## Checking exit code to avoid breaking when read-only disk boot without ro-mode-init or grub-live.
if ! pam_faillock_output="$(faillock --user "$PAM_USER" 2>&1)" ; then
true "$0: faillock non-zero exit code."
exit 0
fi
if [ "$pam_faillock_output" = "" ]; then
true "$0: no failed login"
exit 0
fi
## Example:
## example pam_faillock_output (stdout):
## user:
## When Type Source Valid
## 2021-08-10 16:26:33 RHOST V
## 2021-08-10 16:26:54 RHOST V
## example pam_faillock_output (stderr):
## faillock: No user name supplied.
## Usage: faillock [--dir /path/to/tally-directory] [--user username] [--reset]
## Get first line.
#pam_faillock_output_first_line="$(echo "$pam_faillock_output" | head --lines=1)"
echo "$pam_faillock_output" | read -t 10 -r pam_faillock_output_first_line || true