Only update limits when needed

This commit is contained in:
Bob Mottram 2017-08-05 23:07:31 +01:00
parent 7e24becb9c
commit c1650ae415
1 changed files with 10 additions and 4 deletions

View File

@ -473,14 +473,18 @@ function limit_user_logins {
if ! grep -q '* hard maxsyslogins' /etc/security/limits.conf; then
echo '* hard maxsyslogins 10' >> /etc/security/limits.conf
else
sed -i 's|hard maxsyslogins.*|hard maxsyslogins 10|g' /etc/security/limits.conf
if ! grep -q '* hard maxsyslogins 10' /etc/security/limits.conf; then
sed -i 's|hard maxsyslogins.*|hard maxsyslogins 10|g' /etc/security/limits.conf
fi
fi
# Max logins for each user
if ! grep -q '* hard maxlogins' /etc/security/limits.conf; then
echo '* hard maxlogins 2' >> /etc/security/limits.conf
else
sed -i 's|hard maxlogins.*|hard maxlogins 2|g' /etc/security/limits.conf
if ! grep -q '* hard maxlogins 2' /etc/security/limits.conf; then
sed -i 's|hard maxlogins.*|hard maxlogins 2|g' /etc/security/limits.conf
fi
fi
}
@ -609,10 +613,12 @@ function lockdown_permissions {
}
function disable_core_dumps {
if ! grep -q '* hard core 0' /etc/security/limits.conf; then
if ! grep -q '* hard core' /etc/security/limits.conf; then
echo '* hard core 0' >> /etc/security/limits.conf
else
sed -i 's|hard core.*|hard core 0|g' /etc/security/limits.conf
if ! grep -q '* hard core 0' /etc/security/limits.conf; then
sed -i 's|hard core.*|hard core 0|g' /etc/security/limits.conf
fi
fi
}