[url=][/url]
1 #!/bin/sh 2 ########################################################### 3 # checkpsw.sh (C) 2004 Mathias Sundman <mathias@openvpn.se> 4 # 5 # This script will authenticate OpenVPN users against 6 # a plain text file. The passfile should simply contain 7 # one row per user with the username first followed by 8 # one or more space(s) or tab(s) and then the password. 9 PASSFILE="/etc/openvpn/psw-file"10 LOG_FILE="/etc/openvpn/openvpn-password.log"11 TIME_STAMP=`date "+%Y-%m-%d %T"`12 ###########################################################13 if [ ! -r "${PASSFILE}" ]; then14 echo "${TIME_STAMP}: Could not open password file \"${PASSFILE}\" for reading." >> ${LOG_FILE}15 exit 116 fi17 CORRECT_PASSWORD=`awk '!/^;/&&!/^#/&&$1=="'${username}'"{print $2;exit}' ${PASSFILE}`18 if [ "${CORRECT_PASSWORD}" = "" ]; then19 echo "${TIME_STAMP}: User does not exist: username=\"${username}\", password=\"${password}\"." >> ${LOG_FILE}20 exit 121 fi22 if [ "${password}" = "${CORRECT_PASSWORD}" ]; then23 echo "${TIME_STAMP}: Successful authentication: username=\"${username}\"." >> ${LOG_FILE}24 exit 025 fi26 echo "${TIME_STAMP}: Incorrect password: username=\"${username}\", password=\"${password}\"." >> ${LOG_FILE}27 exit 1[url=][/url]