summaryrefslogtreecommitdiffstats
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
commita7a7e967580c8ef4fa4341aa8b8877128e7d822a (patch)
treefa9d3a67f636d56b8c943e7228de5ad33e4d9acc
parente457a3e615b695cfd98e7d54594e5a3663562b06 (diff)
downloadfreeipa-a7a7e967580c8ef4fa4341aa8b8877128e7d822a.tar.gz
freeipa-a7a7e967580c8ef4fa4341aa8b8877128e7d822a.tar.xz
freeipa-a7a7e967580c8ef4fa4341aa8b8877128e7d822a.zip
Catch USBError during YubiKey location
https://fedorahosted.org/freeipa/ticket/4693 Reviewed-By: Martin Kosek <mkosek@redhat.com>
-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)