请注意,本文编写于 1814 天前,最后修改于 1814 天前,其中某些信息可能已经过时。
LOG_FILE="/etc/openvpn/openvpn_pw.log"
TIME_STAMP=`date "+%Y-%m-%d %T"`
CORRECT_PASSWORD=`/usr/bin/mysql -uopenvpn -popenvpn -h10.10.10.10 openvpn -e "select password from user where username = '${username}' and enabled = true and expire_date > now();G" --skip-column-name |tail -1`
MD5PASSWORD=`echo -n ${password}|md5sum|awk '{print $1}'`
if [ "${CORRECT_PASSWORD}" = "" ]; then
echo "${TIME_STAMP}: User does not exist: username="${username}", password="${password}"." >> ${LOG_FILE}
exit 1
fi
if [ "$MD5PASSWORD" = "${CORRECT_PASSWORD}" ]; then
echo "${TIME_STAMP} Successful authentication username: ${username} IP: $ifconfig_pool_remote_ip RemoteIP: $trusted_ip" >> ${LOG_FILE}
exit 0
fi
echo "${TIME_STAMP}: Incorrect password: username="${username}", password="${password}"." >> ${LOG_FILE}
exit 1