File: //opt/BCLinux/bse/secure_set/s08_fileProperty
#!/bin/sh
#=====================================================================
InsertSection "Set the file property..."
if [ $SET_FILE_PROPERTY -eq 1 ]; then
#---------------------------------------------------
#record original property of file and dir
touch /etc/bse.d/fdproperty_record
pro_record="/etc/bse.d/fdproperty_record"
if [[ ! -s $pro_record ]];then
IS_EXIST=`egrep -v '^#|^$' ${PROFILE} | grep chmod_644_file |wc -l`
if [ "${IS_EXIST}" = "1" ];then
for i in $CHMOD_644_FILE
do
if [ -e $i ];then
pro_val=`stat -c %a $i`
echo "$i=$pro_val">>$pro_record
fi
done
fi
IS_EXIST=`egrep -v '^#|^$' ${PROFILE} | grep chmod_750_file |wc -l`
if [ "${IS_EXIST}" = "1" ];then
for i in $CHMOD_750_FILE
do
if [ -e $i ];then
pro_val=`stat -c %a $i`
echo "$i=$pro_val">>$pro_record
fi
done
fi
IS_EXIST=`egrep -v '^#|^$' ${PROFILE} | grep chmod_600_file |wc -l`
if [ "${IS_EXIST}" = "1" ];then
for i in $CHMOD_600_FILE
do
if [ -e $i ];then
pro_val=`stat -c %a $i`
echo "$i=$pro_val">>$pro_record
fi
done
fi
IS_EXIST=`egrep -v '^#|^$' ${PROFILE} | grep chmod_400_file |wc -l`
if [ "${IS_EXIST}" = "1" ];then
for i in $CHMOD_400_FILE
do
if [ -e $i ];then
pro_val=`stat -c %a $i`
echo "$i=$pro_val">>$pro_record
fi
done
fi
fi
#-----------------------------------------------------------------------
# chmod file and dir
IS_EXIST=`egrep -v '^#|^$' ${PROFILE} | grep chmod_644_file |wc -l`
if [ "${IS_EXIST}" = "1" ];then
for i in $CHMOD_644_FILE
do
if [ -e $i ];then
chmod 644 ${i}
fi
done
fi
IS_EXIST=`egrep -v '^#|^$' ${PROFILE} | grep chmod_750_file |wc -l`
if [ "${IS_EXIST}" = "1" ];then
for i in $CHMOD_750_FILE
do
if [ -e $i ];then
chmod 750 ${i}
fi
done
fi
IS_EXIST=`egrep -v '^#|^$' ${PROFILE} | grep chmod_600_file |wc -l`
if [ "${IS_EXIST}" = "1" ];then
for i in $CHMOD_600_FILE
do
if [ -e $i ];then
chmod 600 ${i}
fi
done
fi
IS_EXIST=`egrep -v '^#|^$' ${PROFILE} | grep chmod_400_file |wc -l`
if [ "${IS_EXIST}" = "1" ];then
for i in $CHMOD_400_FILE
do
if [ -e $i ];then
chmod 400 ${i}
fi
done
fi
IS_EXIST=`egrep -v '^#|^$' ${PROFILE} | grep chmod_751_file |wc -l`
if [ "${IS_EXIST}" = "1" ];then
for i in $CHMOD_751_FILE
do
if [ -e $i ];then
chmod 751 ${i}
fi
done
fi
logtext "Set the file property finished"
Display --indent 2 --text "- Set the file property... " --result FINISHED --color GREEN
else
Display --indent 2 --text "- Skip set security file property due to config file... " --result SKIPPING --color YELLOW
fi