pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0066-Catch-USBError-during-YubiKey-location.patch

e3ffab
From 238225b49c52d44ab926c97c0f3bf9d93230d99a Mon Sep 17 00:00:00 2001
e3ffab
From: Nathaniel McCallum <npmccallum@redhat.com>
e3ffab
Date: Fri, 7 Nov 2014 10:47:43 -0500
e3ffab
Subject: [PATCH] Catch USBError during YubiKey location
e3ffab
e3ffab
https://fedorahosted.org/freeipa/ticket/4693
e3ffab
e3ffab
Reviewed-By: Martin Kosek <mkosek@redhat.com>
e3ffab
---
e3ffab
 ipalib/plugins/otptoken_yubikey.py | 7 +++++--
e3ffab
 1 file changed, 5 insertions(+), 2 deletions(-)
e3ffab
e3ffab
diff --git a/ipalib/plugins/otptoken_yubikey.py b/ipalib/plugins/otptoken_yubikey.py
e3ffab
index 7095887ac7cdf5d4b7d0d30edc6cab0222246664..4c2594182c08a9de3f2f5861aac60b39a9ce022a 100644
e3ffab
--- a/ipalib/plugins/otptoken_yubikey.py
e3ffab
+++ b/ipalib/plugins/otptoken_yubikey.py
e3ffab
@@ -25,6 +25,7 @@ from ipalib.plugins.otptoken import otptoken
e3ffab
 
e3ffab
 import os
e3ffab
 
e3ffab
+import usb.core
e3ffab
 import yubico
e3ffab
 
e3ffab
 __doc__ = _("""
e3ffab
@@ -81,8 +82,10 @@ class otptoken_add_yubikey(Command):
e3ffab
         # Open the YubiKey
e3ffab
         try:
e3ffab
             yk = yubico.find_yubikey()
e3ffab
-        except yubico.yubikey.YubiKeyError, e:
e3ffab
-            raise NotFound(reason=_('No YubiKey found'))
e3ffab
+        except usb.core.USBError as e:
e3ffab
+            raise NotFound(reason="No YubiKey found: %s" % e.strerror)
e3ffab
+        except yubico.yubikey.YubiKeyError as e:
e3ffab
+            raise NotFound(reason=e.reason)
e3ffab
 
e3ffab
         assert yk.version_num() >= (2, 1)
e3ffab
 
e3ffab
-- 
e3ffab
2.1.0
e3ffab