summaryrefslogtreecommitdiff
path: root/duo_openvpn.py
diff options
context:
space:
mode:
Diffstat (limited to 'duo_openvpn.py')
-rwxr-xr-xduo_openvpn.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/duo_openvpn.py b/duo_openvpn.py
index 6a09e55..b5f890a 100755
--- a/duo_openvpn.py
+++ b/duo_openvpn.py
@@ -5,8 +5,19 @@
# Copyright 2011 Duo Security, Inc.
#
-import os, sys, urllib, hashlib, hmac, base64, json, syslog
-from https_wrapper import CertValidatingHTTPSConnection
+import syslog, sys
+
+def log(msg):
+ msg = 'Duo OpenVPN: %s' % msg
+ syslog.syslog(msg)
+
+try:
+ import os, urllib, hashlib, hmac, base64, json
+ from https_wrapper import CertValidatingHTTPSConnection
+except ImportError, e:
+ log('ImportError: %s' % e)
+ log('Please make sure you\'re running Python 2.6 or newer')
+ raise
API_RESULT_AUTH = 'auth'
API_RESULT_ALLOW = 'allow'
@@ -69,10 +80,6 @@ def api(ikey, skey, host, method, path, **kwargs):
except (ValueError, KeyError):
raise RuntimeError('Received bad response: %s' % data)
-def log(msg):
- msg = 'Duo OpenVPN: %s' % msg
- syslog.syslog(msg)
-
def success(control):
log('writing success code to %s' % control)