Introduction
The following can be implemented to set a custom set of ulmit settings set by Fork Bomb Protection. When done Fork Bomb Protection will show disabled in WHM though.
Procedure
1. Make sure Fork Bomb Protection is disabled in WHM.
2. First create the following file /etc/profile.d/mylimits.sh with contents:
# Custom Shell Fork Bomb Protect
ulimit -n 4096 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
LIMITUSER=$USER
if [ -e "/usr/bin/whoami" ]; then
LIMITUSER=$(/usr/bin/whoami)
fi
# Limit the user only if we are not root and are a regular user (UID greater
# than or equal to UID_MIN).
if [ "$LIMITUSER" != "root" ] &&
! id -Gn | grep -qsP '(^| )wheel( |$)' &&
[ "$(id -u)" -ge "$( (grep -s '^UID_MIN' /etc/login.defs || echo 'x 500') | awk '{print $2}')" ]
then
ulimit -n 1200 -u 250 -m 200000 -d 200000 -s 8192 -c 200000 -v unlimited 2>/dev/null
else
ulimit -n 4096 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
fi
The main change so far is increasing the number of open files to 1200 and the number of user processes to 250.
3. Set permissions for /etc/profile.d/mylimits.sh with:
chmod 755 /etc/profile.d/mylimits.sh
4. Next we need this to be contained in /etc/bashrc and /etc/profile by doing the following to concatenate to those files:
cat /etc/profile.d/mylimits.sh >> /etc/bashrc
cat /etc/profile.d/mylimits.sh >> /etc/profile
At this point, the custom Fork Bomb Protection settings are enabled. Please keep in mind the user will need to log out and log in again so the /etc/profile and /etc/bashrc files get loaded for the user.