Merge pull request #305 from DMHalford/pam-info-failed_login_counter-fix

Prevent erroneous "Login blocked after [negative number] attempts" errors
This commit is contained in:
Patrick Schleizer 2025-05-18 06:35:23 -04:00 committed by GitHub
commit e478750814
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -163,9 +163,9 @@ pam_faillock_output_count="$(echo "$pam_faillock_output" | wc -l)"
## example pam_faillock_output_count:
## 4
## Do not count the first two informational textual output lines
## (starting with "user:" and "When").
failed_login_counter=$(( pam_faillock_output_count - 2 ))
## 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" )
## example failed_login_counter:
## 2