#!/bin/sh
#BOOTUP=color
#RES_COL=60
#MOVE_TO_COL="echo -en \033[${RES_COL}G"
#SETCOLOR_SUCCESS="echo -en \033[1;32m"
#SETCOLOR_FAILURE="echo -en \033[1;31m"
#SETCOLOR_WARNING="echo -en \033[1;33m"
#SETCOLOR_NORMAL="echo -en \033[0;39m"
# source function library
. /etc/rc.d/init.d/functions
$ifpass
#set the variables to false
#ignore sign <CTRL-C>
trap "" 1 2 3 15
#
SAVEDSTTY=`stty -g`
echo -e "
\033[1;32mYou Are Logging Into a Sensitive Area\033[0m
"
echo -e "\033[1;33m`cat <<EOF
##############################################################
This script is checking user for login.
Not checking passed user is do not login.
##############################################################
EOF`\033[0m
"
echo -n "Enter your name :"
read NAME
#hide the characters typed in
stty -echo
echo -n "Enter your password :"
read PASSWD
#back on agian
stty $SAVEDSTTY
echo -e "
"
#Check login name
if [ "$NAME" = "nobody" ] && [ "$PASSWD" = "123456" ] ; then
echo -n $"Correct user id and password given";success $"$NAME success login";echo
echo -e "`date`
`w`
" | mail -s "$HOSTNAME Monitor" root@localhost
#Connection to Mysql Server Auth
check=`mysql -uadmin -p123456 -h root@localhost rlogin -e "select action from users where username='"$NAME"' and password=password('"$PASSWD"');" 2> /dev/null`
if [ $? != 0 ] ; then
echo -e "$HOSTNAME do not connection mysql.
" | mail -s "$HOSTNAME ifpass Wrong!" root@localhost
fi
if [ -n "$check" ] ; then
echo -n $"Correct user id and password given";success $"$NAME success login";echo
echo -e "User:$NAME loging success
`date`
`w`
" | mail -s "$HOSTNAME Monitor" root@localhost
else
echo -n $"System: Sorry wrong password or userid";failure $"$NAME failure login";echo
echo -e "User:$NAME password is wrong
`date`
`w`
" | mail -s "$HOSTNAME Monitor" root@localhost
for pid in `ps|grep bash|awk '{print $1}'`
do
kill -9 $pid
done
exit 1
fi
fi
exit 0