diff options
author | Adam Goodman <akgood@duosecurity.com> | 2012-10-09 12:24:41 -0400 |
---|---|---|
committer | Adam Goodman <akgood@duosecurity.com> | 2012-10-09 12:30:25 -0400 |
commit | 9b4e1d0147d94a0328cf92aa6d006d161ed050dc (patch) | |
tree | 2b09651f278f4b92d9e3e2fc77ef97c94eb01b64 | |
parent | 2a07194babfaef11f426106939734851ef5c2fa2 (diff) | |
download | openvpn-duo-plugin-9b4e1d0147d94a0328cf92aa6d006d161ed050dc.tar.gz openvpn-duo-plugin-9b4e1d0147d94a0328cf92aa6d006d161ed050dc.zip |
log importerrors in duo_openvpn.py to syslog (to better detect old python versions)
-rwxr-xr-x | duo_openvpn.py | 19 |
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) |