Browse Source

Use logger for cn-filter

pull/2/head
Victor Laborie 2 years ago
parent
commit
d6469e4e5b
1 changed files with 3 additions and 5 deletions
  1. +3
    -5
      cn-filter.sh

+ 3
- 5
cn-filter.sh View File

@@ -9,18 +9,16 @@
# client-connect <path-to-cn-filter>/cn-filter.sh
#

set -eu
set -u

DATE="$(date +'%b %d %H:%M:%S')"
LOG_FILE="/var/log/openvpn/auth.log"
AUTH_FILE="/etc/openvpn/authorized_cns"

grep -qE "^${common_name}$" "${AUTH_FILE}"
if [ "$?" -eq 0 ]; then
echo "${DATE} - Accepted login for ${common_name} from ${trusted_ip} port ${trusted_port}" >> "${LOG_FILE}"
logger -i -t openvpn-cn-filter -p auth.info "Accepted login for ${common_name} from ${trusted_ip} port ${trusted_port}"
exit 0
else
echo "${DATE} - Failed login for ${common_name} from ${trusted_ip} port ${trusted_port}" >> "${LOG_FILE}"
logger -i -t openvpn-cn-filter -p auth.notice "Failed login for ${common_name} from ${trusted_ip} port ${trusted_port}"
fi

exit 1

Loading…
Cancel
Save