From 7f2ba0980d17360fc014c6a412fc4ee57e1032fd Mon Sep 17 00:00:00 2001 From: Patrick Schleizer Date: Sun, 18 May 2025 06:40:50 -0400 Subject: [PATCH] refactoring --- usr/libexec/security-misc/pam-info | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/usr/libexec/security-misc/pam-info b/usr/libexec/security-misc/pam-info index 0559ea3..8998641 100755 --- a/usr/libexec/security-misc/pam-info +++ b/usr/libexec/security-misc/pam-info @@ -164,12 +164,18 @@ pam_faillock_output_count="$(echo "$pam_faillock_output" | wc -l)" ## 4 ## 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 )) -gt 0 ] && echo $(( pam_faillock_output_count - 2 )) || echo "0" ) +failed_login_counter=$(( pam_faillock_output_count - 2 )) ## example failed_login_counter: ## 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 true "$0: INFO: Failed login counter is 0, ok." exit 0