HEX
Server: nginx/1.16.1
System: Linux ecs-04358622 4.19.90-2107.6.0.0100.oe1.bclinux.x86_64 #1 SMP Wed Dec 1 19:59:44 CST 2021 x86_64
User: nginx (994)
PHP: 8.0.0
Disabled: NONE
Upload Files
File: //opt/BCLinux/bse/secure_check/c22_resourceLimit
#!/bin/sh

#=======================================================
InsertSection "check the resource limit"


IS_EXIST=`egrep -v '^$|^#' /etc/security/limits.conf  | grep soft | grep core | wc -l`
if [ ${IS_EXIST} -gt 0 ] ; then
    VALUE=`egrep -v '^$|^#' /etc/security/limits.conf  | grep soft | awk  -F " " '{print $4}'`
    if [[ ${VALUE} -ne  0 ]];then
        echo "c22 soft_core" >> $RESULT_FILE
        echo "" >> $RESULT_FILE
        logtext "WRN_C22_01: $(loadtext TXT_WRN_C22_01)"
        logtext "Suggestion: $(loadtext TXT_SUG_C22_01)"
        Display --indent 2 --text "- Check if the soft core limits is ok... " --result WARNING --color RED
        AddHP 0 1
    else
        logtext "The system soft core limit is '0', check OK"
        Display --indent 2 --text "- Check if the soft core limits is ok... " --result OK --color GREEN
        AddHP 1 1
    fi
else
    echo "c22 soft_core" >> $RESULT_FILE
    echo "" >> $RESULT_FILE
    logtext "WRN_C22_02: $(loadtext TXT_WRN_C22_02)"
    logtext "Suggestion: $(loadtext TXT_SUG_C22_01)"
    Display --indent 2 --text "- Check if the soft core limits is ok... " --result WARNING --color RED
    Display --indent 2 --text "This system has no soft core limit set"
    AddHP 0 1
fi


IS_EXIST=`egrep -v '^$|^#' /etc/security/limits.conf  | grep hard | grep core | wc -l`
if [ ${IS_EXIST} -gt 0 ] ; then
    VALUE=`egrep -v '^$|^#' /etc/security/limits.conf  | grep hard | awk  -F " " '{print $4}'`
    if [[ ${VALUE} -ne  0 ]];then
        echo "c22 hard_core" >> $RESULT_FILE
        echo "" >> $RESULT_FILE
        logtext "WRN_C22_03: $(loadtext TXT_WRN_C22_03)"
        logtext "Suggestion: $(loadtext TXT_SUG_C22_02)"
        Display --indent 2 --text "- Check if the hard core limits is ok... " --result WARNING --color RED
        AddHP 0 1
    else
        logtext "The system hard core limit is '0', check OK"
        Display --indent 2 --text "- Check if the hard core limits is ok... " --result OK --color GREEN
        AddHP 1 1
    fi
else
    echo "c22 hard_core" >> $RESULT_FILE
    echo "" >> $RESULT_FILE
    logtext "WRN_C22_04: $(loadtext TXT_WRN_C22_04)"
    logtext "Suggestion: $(loadtext TXT_SUG_C22_02)"
    Display --indent 2 --text "- Check if the hard core limits is ok... " --result WARNING --color RED
    Display --indent 2 --text "This system has no hard core limit set"
    AddHP 0 1

fi