Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  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.  
  10. PASSFILE="/etc/openvpn/psw-file"
  11. LOG_FILE="/var/log/openvpn/password.log"
  12. TIME_STAMP=`date "+%Y-%m-%d %T"`
  13.  
  14. ###########################################################
  15. if [ ! -r "${PASSFILE}" ]; then
  16. echo "${TIME_STAMP}: Could not open password file \"${PASSFILE}\" for reading." >> ${LOG_FILE}
  17. exit 1
  18. fi
  19.  
  20. CORRECT_PASSWORD=`awk '!/^;/&&!/^#/&&$1=="'${username}'"{print $2;exit}' ${PASSFILE}`
  21.  
  22. if [ "${CORRECT_PASSWORD}" = "" ]; then
  23. echo "${TIME_STAMP}: User does not exist: username=\"${username}\", password=\"${password}\"." >> ${LOG_FILE}
  24. exit 1
  25. fi
  26.  
  27. if [ "${password}" = "${CORRECT_PASSWORD}" ]; then
  28. echo "${TIME_STAMP}: Successful authentication: username=\"${username}\"." >> ${LOG_FILE}
  29. exit 0
  30. fi
  31.  
  32. echo "${TIME_STAMP}: Incorrect password: username=\"${username}\", password=\"${password}\"." >> ${LOG_FILE}
  33.  
  34. exit 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement