mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Catch USBError during YubiKey location
https://fedorahosted.org/freeipa/ticket/4693 Reviewed-By: Martin Kosek <mkosek@redhat.com>
This commit is contained in:
committed by
Martin Kosek
parent
c13862104a
commit
b3a6701e73
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user