File: //opt/BCLinux/bse/secure_set/s09_loginDefs
#!/bin/sh
#=====================================================================
InsertSection "Set the PASS_MAX_DAYS in /etc/login.defs..."
if [ $SET_PASS_MAX_DAYS -eq 1 ]; then
cp -np /etc/login.defs /etc/login.defs_bak
IS_EXIST=`egrep -v '^#|^$' /etc/login.defs | grep 'PASS_MAX_DAYS' | wc -l`
if [ "${IS_EXIST}" = "0" ] ; then
echo -e "PASS_MAX_DAYS ${PASS_MAX_DAYS_VALUE}\n\n" >> /etc/login.defs
else
sed -i 's/^PASS_MAX_DAYS.*/PASS_MAX_DAYS '$PASS_MAX_DAYS_VALUE'/' /etc/login.defs
fi
cat /etc/login.defs |grep "PASS_MAX_DAYS"|grep -v "#" | awk -F " " '{print $2}' |while read count
do
if [ $count -gt 90 ];then
#echo "c09" >> $RESULT_FILE
#echo "" >> $RESULT_FILE
logtext "the PASS_MAX_DAYS is not safe"
Display --indent 2 --text "- Set the PASS_MAX_DAYS value... " --result FAILED --color RED
#AddHP 0 1
else
logtext "PASS_MAX_DAYS value is safe, checking ok"
Display --indent 2 --text "- Set the PASS_MAX_DAYS value... " --result FINISHED --color GREEN
#AddHP 1 1
fi
done
else
Display --indent 2 --text "- Skip set PASS_MAX_DAYS due to config file... " --result SKIPPING --color YELLOW
fi
#=====================================================================
InsertSection "Set the PASS_MIN_DAYS in /etc/login.defs..."
if [ $SET_PASS_MIN_DAYS -eq 1 ]; then
IS_EXIST=`egrep -v '^#|^$' /etc/login.defs | grep 'PASS_MIN_DAYS' | wc -l`
if [ "${IS_EXIST}" = "0" ] ; then
echo -e "PASS_MIN_DAYS ${PASS_MIN_DAYS_VALUE}\n\n" >> /etc/login.defs
else
sed -i 's/^PASS_MIN_DAYS.*/PASS_MIN_DAYS '${PASS_MIN_DAYS_VALUE}'/' /etc/login.defs
fi
cat /etc/login.defs |grep "PASS_MIN_DAYS"|grep -v "#" | awk -F " " '{print $2}' |while read count
do
if [ $count -lt 6 ];then
logtext "the PASS_MIN_DAYS is not safe with value: $count"
Display --indent 2 --text "- Set the PASS_MIN_DAYS value... " --result FAILED --color RED
#AddHP 0 1
else
logtext "PASS_MIN_DAYS value is safe with: $count, checking ok"
Display --indent 2 --text "- Set the PASS_MIN_DAYS value... " --result FINISHED --color GREEN
#AddHP 1 1
fi
done
else
Display --indent 2 --text "- Skip set PASS_MIN_DAYS due to config file... " --result SKIPPING --color YELLOW
fi
#=====================================================================
InsertSection "Set the PASS_MIN_LEN in /etc/login.defs..."
if [ $SET_PASS_MIN_LEN -eq 1 ]; then
IS_EXIST=`egrep -v '^#|^$' /etc/login.defs | grep 'PASS_MIN_LEN' | wc -l`
if [ "${IS_EXIST}" = "0" ] ; then
echo -e "PASS_MIN_LEN ${PASS_MIN_LEN_VALUE}\n\n" >> /etc/login.defs
else
sed -i 's/^PASS_MIN_LEN.*/PASS_MIN_LEN '${PASS_MIN_LEN_VALUE}'/' /etc/login.defs
fi
cat /etc/login.defs |grep "PASS_MIN_LEN"|grep -v "#" | awk -F " " '{print $2}' |while read count
do
if [ $count -lt 8 ];then
logtext "the PASS_MIN_LEN is not safe with value: $count"
Display --indent 2 --text "- Set the PASS_MIN_LEN value... " --result FAILED --color RED
#AddHP 0 1
else
logtext "PASS_MIN_LEN value is safe with: $count, checking ok"
Display --indent 2 --text "- Set the PASS_MIN_LEN value... " --result FINISHED --color GREEN
#AddHP 1 1
fi
done
else
Display --indent 2 --text "- Skip set PASS_MIN_LEN due to config file... " --result SKIPPING --color YELLOW
fi
#=====================================================================
InsertSection "Set the PASS_WARN_AGE in /etc/login.defs..."
if [ $SET_PASS_WARN_AGE -eq 1 ]; then
IS_EXIST=`egrep -v '^#|^$' /etc/login.defs | grep 'PASS_WARN_AGE' | wc -l`
if [ "${IS_EXIST}" = "0" ] ; then
echo -e "PASS_WARN_AGE ${PASS_WARN_AGE_VALUE}\n\n" >> /etc/login.defs
else
sed -i 's/^PASS_WARN_AGE.*/PASS_WARN_AGE '${PASS_WARN_AGE_VALUE}'/' /etc/login.defs
fi
cat /etc/login.defs |grep "PASS_WARN_AGE"|grep -v "#" | awk -F " " '{print $2}' |while read count
do
if [ $count -lt 30 ];then
logtext "the PASS_WARN_AGE is not safe with value: $count"
Display --indent 2 --text "- Set the PASS_WARN_AGE value... " --result FAILED --color RED
#AddHP 0 1
else
logtext "PASS_WARN_AGE value is safe with: $count, checking ok"
Display --indent 2 --text "- Set the PASS_WARN_AGE value... " --result FINISHED --color GREEN
#AddHP 1 1
fi
done
else
Display --indent 2 --text "- Skip set PASS_WARN_AGE due to config file... " --result SKIPPING --color YELLOW
fi