summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/otptoken_yubikey.py
diff options
context:
space:
mode:
authorNathaniel McCallum <npmccallum@redhat.com>2014-11-07 10:47:43 -0500
committerMartin Kosek <mkosek@redhat.com>2014-11-25 16:44:00 +0100
commitb3a6701e73f6ccd4dff1dab47554381f42d40bb4 (patch)
tree782d81a81f75dd86dc13b9d54a6e97066d9220a4 /ipalib/plugins/otptoken_yubikey.py
parentc13862104ab64cda81c86c51b849c8d01c3c9187 (diff)
downloadfreeipa-b3a6701e73f6ccd4dff1dab47554381f42d40bb4.tar.gz
freeipa-b3a6701e73f6ccd4dff1dab47554381f42d40bb4.tar.xz
freeipa-b3a6701e73f6ccd4dff1dab47554381f42d40bb4.zip
Catch USBError during YubiKey location
https://fedorahosted.org/freeipa/ticket/4693 Reviewed-By: Martin Kosek <mkosek@redhat.com>
Diffstat (limited to 'ipalib/plugins/otptoken_yubikey.py')
-rw-r--r--ipalib/plugins/otptoken_yubikey.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/ipalib/plugins/otptoken_yubikey.py b/ipalib/plugins/otptoken_yubikey.py
index 7095887ac..4c2594182 100644
--- a/ipalib/plugins/otptoken_yubikey.py
+++ b/ipalib/plugins/otptoken_yubikey.py
@@ -25,6 +25,7 @@ from ipalib.plugins.otptoken import otptoken
import os
+import usb.core
import yubico
__doc__ = _("""
@@ -81,8 +82,10 @@ class otptoken_add_yubikey(Command):
# Open the YubiKey
try:
yk = yubico.find_yubikey()
- except yubico.yubikey.YubiKeyError, e:
- raise NotFound(reason=_('No YubiKey found'))
+ except usb.core.USBError as e:
+ raise NotFound(reason="No YubiKey found: %s" % e.strerror)
+ except yubico.yubikey.YubiKeyError as e:
+ raise NotFound(reason=e.reason)
assert yk.version_num() >= (2, 1)