Use pam_faillock instead of pam_tally for bullseye (#56)

Fix #55
See https://github.com/linux-pam/linux-pam/releases/tag/v1.4.0
pam_tally is deprecated and replaced by pam_faillock

Co-authored-by: GoldenKiwi <thibault.dewailly@corp.ovh.com>
This commit is contained in:
Thibault Ayanides 2021-02-17 11:36:58 +01:00 committed by GitHub
parent fa111bc0d0
commit 1a7dd5893a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -18,8 +18,8 @@ HARDENING_LEVEL=3
DESCRIPTION="Set lockout for failed password attemps." DESCRIPTION="Set lockout for failed password attemps."
PACKAGE='libpam-modules-bin' PACKAGE='libpam-modules-bin'
PATTERN_AUTH='^auth[[:space:]]*required[[:space:]]*pam_tally[2]?\.so' PATTERN_AUTH='^auth[[:space:]]*required[[:space:]]*pam_((tally[2]?)|(faillock))\.so'
PATTERN_ACCOUNT='pam_tally[2]?\.so' PATTERN_ACCOUNT='pam_((tally[2]?)|(faillock))\.so'
FILE_AUTH='/etc/pam.d/common-auth' FILE_AUTH='/etc/pam.d/common-auth'
FILE_ACCOUNT='/etc/pam.d/common-account' FILE_ACCOUNT='/etc/pam.d/common-account'
@ -59,14 +59,22 @@ apply() {
ok "$PATTERN_AUTH is present in $FILE_AUTH" ok "$PATTERN_AUTH is present in $FILE_AUTH"
else else
warn "$PATTERN_AUTH is not present in $FILE_AUTH, adding it" warn "$PATTERN_AUTH is not present in $FILE_AUTH, adding it"
if [ 10 -ge "$DEB_MAJ_VER" ]; then
add_line_file_before_pattern "$FILE_AUTH" "auth required pam_tally2.so onerr=fail audit silent deny=5 unlock_time=900" "# pam-auth-update(8) for details." add_line_file_before_pattern "$FILE_AUTH" "auth required pam_tally2.so onerr=fail audit silent deny=5 unlock_time=900" "# pam-auth-update(8) for details."
else
add_line_file_before_pattern "$FILE_AUTH" "auth required pam_faillock.so onerr=fail audit silent deny=5 unlock_time=900" "# pam-auth-update(8) for details."
fi
fi fi
does_pattern_exist_in_file "$FILE_ACCOUNT" "$PATTERN_ACCOUNT" does_pattern_exist_in_file "$FILE_ACCOUNT" "$PATTERN_ACCOUNT"
if [ "$FNRET" = 0 ]; then if [ "$FNRET" = 0 ]; then
ok "$PATTERN_ACCOUNT is present in $FILE_ACCOUNT" ok "$PATTERN_ACCOUNT is present in $FILE_ACCOUNT"
else else
warn "$PATTERN_ACCOUNT is not present in $FILE_ACCOUNT, adding it" warn "$PATTERN_ACCOUNT is not present in $FILE_ACCOUNT, adding it"
add_line_file_before_pattern "$FILE_ACCOUNT" "account required pam_tally.so" "# pam-auth-update(8) for details." if [ 10 -ge "$DEB_MAJ_VER" ]; then
add_line_file_before_pattern "$FILE_ACCOUNT" "account required pam_tally2.so" "# pam-auth-update(8) for details."
else
add_line_file_before_pattern "$FILE_ACCOUNT" "account required pam_faillock.so" "# pam-auth-update(8) for details."
fi
fi fi
} }

View File

@ -13,7 +13,7 @@ test_audit() {
describe Checking resolved state describe Checking resolved state
register_test retvalshouldbe 0 register_test retvalshouldbe 0
register_test contain "[ OK ] ^auth[[:space:]]*required[[:space:]]*pam_tally[2]?\.so is present in /etc/pam.d/common-auth" register_test contain "[ OK ] ^auth[[:space:]]*required[[:space:]]*pam_((tally[2]?)|(faillock))\.so is present in /etc/pam.d/common-auth"
register_test contain "[ OK ] pam_tally[2]?\.so is present in /etc/pam.d/common-account" register_test contain "[ OK ] pam_((tally[2]?)|(faillock))\.so is present in /etc/pam.d/common-account"
run resolved /opt/debian-cis/bin/hardening/"${script}".sh --audit-all run resolved /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
} }