Only change pam values when needed

This commit is contained in:
Bob Mottram 2017-08-05 23:13:28 +01:00
parent c1650ae415
commit f7f323b763
1 changed files with 9 additions and 3 deletions

View File

@ -458,13 +458,17 @@ function set_max_login_tries {
if ! grep -q ' deny=' /etc/pam.d/common-auth; then
sed -i "/pam_deny.so/a auth required\t\t\tpam_tally.so onerr=fail no_lock_time per_user deny=$max_tries" /etc/pam.d/common-auth
else
sed -i "s| deny=.*| deny=$max_tries|g" /etc/pam.d/common-auth
if ! grep -q " deny=$max_tries" /etc/pam.d/common-auth; then
sed -i "s| deny=.*| deny=$max_tries|g" /etc/pam.d/common-auth
fi
fi
if ! grep -q ' deny=' /etc/pam.d/common-account; then
sed -i '/pam_deny.so/a account required\t\t\tpam_tally.so' /etc/pam.d/common-account
else
sed -i "s| deny=.*| deny=$max_tries|g" /etc/pam.d/common-account
if ! grep -q " deny=$max_tries" /etc/pam.d/common-account; then
sed -i "s| deny=.*| deny=$max_tries|g" /etc/pam.d/common-account
fi
fi
}
@ -630,7 +634,9 @@ function dummy_nologin_command {
}
function disable_null_passwords {
sed -i 's| nullok_secure||g' /etc/pam.d/common-auth
if grep -q ' nullok_secure' /etc/pam.d/common-auth; then
sed -i 's| nullok_secure||g' /etc/pam.d/common-auth
fi
}
function create_usb_canary {