refactoring

This commit is contained in:
Patrick Schleizer 2025-05-18 06:40:50 -04:00
parent 4d1f8c44d2
commit 7f2ba0980d
No known key found for this signature in database
GPG key ID: CB8D50BB77BB3C48

View file

@ -164,12 +164,18 @@ pam_faillock_output_count="$(echo "$pam_faillock_output" | wc -l)"
## 4 ## 4
## Do not count the first two informational textual output lines (starting with "user:" and "When") if present, ## Do not count the first two informational textual output lines (starting with "user:" and "When") if present,
## whilst ensuring failed_login_counter is not set to a negative value. failed_login_counter=$(( pam_faillock_output_count - 2 ))
failed_login_counter=$( [ $(( pam_faillock_output_count - 2 )) -gt 0 ] && echo $(( pam_faillock_output_count - 2 )) || echo "0" )
## example failed_login_counter: ## example failed_login_counter:
## 2 ## 2
## Ensuring failed_login_counter is not set to a negative value.
## https://github.com/Kicksecure/security-misc/pull/305
if [ "$failed_login_counter" -le "0" ]; then
true "$0: WARNING: Failed login counter is negative. Resetting to 0."
failed_login_counter=0
fi
if [ "$failed_login_counter" = "0" ]; then if [ "$failed_login_counter" = "0" ]; then
true "$0: INFO: Failed login counter is 0, ok." true "$0: INFO: Failed login counter is 0, ok."
exit 0 exit 0