File: //opt/BCLinux/bse/secure_set/s07_TMOUT
#!/bin/sh
#=====================================================================
InsertSection "Set the TMOUT..."
if [ $SET_TMOUT -eq 1 ]; then
cp -np /etc/profile /etc/profile_bak
cp -np /etc/csh.cshrc /etc/csh.cshrc_bak
#logtext "set the login timeout."
IS_EXIST=`egrep -v '^#|^$' /etc/profile | grep TMOUT= |wc -l`
if [ "${IS_EXIST}" = "0" ] ; then
logtext "no TMOUT set, adding..."
sed -i '/export \{1,\}TMOUT$/d' /etc/profile
echo "TMOUT=${TMOUT_VALUE}" >> /etc/profile
echo "export TMOUT" >> /etc/profile
echo "set autologout=30" >> /etc/csh.cshrc
else
logtext "exist TMOUT set, check its value..."
OLD_TMOUT_VALUE=`grep -Ev "^#|^$" /etc/profile | grep TMOUT= | tail -1 | awk -F ";" '{print $1}' | awk -F "=" '{print $2}'`
if [[ ${OLD_TMOUT_VALUE} -eq ${TMOUT_VALUE} ]];then
logtext "Right TMOUT set, pass..."
else
logtext "Wrong TMOUT set, set it to ${TMOUT_VALUE}..."
sed -i 's/TMOUT=.*/TMOUT='${TMOUT_VALUE}'/g' /etc/profile
fi
sed -i '/export \{1,\}TMOUT$/d' /etc/profile
echo "export TMOUT" >> /etc/profile
fi
TMOUT_RESULT=`cat /etc/profile|grep TMOUT= |grep -v "#" | awk -F "=" '{print $2}'|tail -1 `
if [[ "${TMOUT_RESULT}" -gt 300 ]]; #unary operator expected
then
logtext "Set the TMOUT failed, the result is ${TMOUT_RESULT}, and is not ok"
Display --indent 2 --text "- Set the TMOUT... " --result FAILED --color RED
#AddHP 0 1
else
logtext "Set the TMOUT finished, checking ok"
Display --indent 2 --text "- Set the TMOUT... " --result FINISHED --color GREEN
fi
else
Display --indent 2 --text "- Skip set TMOUT due to config file... " --result SKIPPING --color YELLOW
fi