mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-05 18:44:06 +08:00
update 2026-07-28 01:38:11
This commit is contained in:
1 parent
20b786ab77
commit
25d570431d
6243 files changed
+2850542
No files matched your search
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
###########################################################
|
||||
# checkpsw.sh (C) 2004 Mathias Sundman
|
||||
#
|
||||
# This script will authenticate OpenVPN users against
|
||||
# a plain text file. The passfile should simply contain
|
||||
# one row per user with the username first followed by
|
||||
# one or more space(s) or tab(s) and then the password.
|
||||
|
||||
PASSFILE="/etc/openvpn/server/psw-file"
|
||||
LOG_FILE="/etc/openvpn/openvpn-password.log"
|
||||
TIME_STAMP=`date "+%Y-%m-%d %T"`
|
||||
|
||||
###########################################################
|
||||
|
||||
if [ ! -r "${PASSFILE}" ]; then
|
||||
echo "${TIME_STAMP}: Could not open password file \"${PASSFILE}\" for reading." >> ${LOG_FILE}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CORRECT_PASSWORD=`awk '!/^;/&&!/^#/&&$1=="'${username}'"{print $2;exit}' ${PASSFILE}`
|
||||
|
||||
if [ "${CORRECT_PASSWORD}" = "" ]; then
|
||||
echo "${TIME_STAMP}: User does not exist: username=\"${username}\", password=\"${password}\"." >> ${LOG_FILE}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${password}" = "${CORRECT_PASSWORD}" ]; then
|
||||
echo "${TIME_STAMP}: Successful authentication: username=\"${username}\"." >> ${LOG_FILE}
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "${TIME_STAMP}: Incorrect password: username=\"${username}\", password=\"${password}\"." >> ${LOG_FILE}
|
||||
exit 1
|
||||
Reference in new issue
Block a user