Detach kernel driver for tool/gnuk_token.py

This commit is contained in:
NIIBE Yutaka
2013-12-13 10:46:03 +09:00
parent 3b140d0120
commit 544c5310d3
2 changed files with 19 additions and 0 deletions

View File

@@ -1,3 +1,8 @@
2013-12-13 Niibe Yutaka <gniibe@fsij.org>
* tool/gnuk_token.py (gnuk_token.stop_gnuk): Detach kernel
driver of HID.
2013-12-12 Niibe Yutaka <gniibe@fsij.org> 2013-12-12 Niibe Yutaka <gniibe@fsij.org>
* src/openpgp-do.c (do_openpgpcard_aid): Coerce to volatile to * src/openpgp-do.c (do_openpgpcard_aid): Coerce to volatile to

View File

@@ -29,6 +29,10 @@ CCID_CLASS = 0x0B
CCID_SUBCLASS = 0x00 CCID_SUBCLASS = 0x00
CCID_PROTOCOL_0 = 0x00 CCID_PROTOCOL_0 = 0x00
HID_CLASS = 0x03
HID_SUBCLASS_NO_BOOT = 0x00
HID_PROTOCOL_0 = 0x00
def icc_compose(msg_type, data_len, slot, seq, param, data): def icc_compose(msg_type, data_len, slot, seq, param, data):
return pack('<BiBBBH', msg_type, data_len, slot, seq, 0, param) + data return pack('<BiBBBH', msg_type, data_len, slot, seq, 0, param) + data
@@ -75,6 +79,14 @@ class gnuk_token(object):
self.__alt = interface.alternateSetting self.__alt = interface.alternateSetting
self.__conf = configuration self.__conf = configuration
self.__hid_intf = None
for intf in configuration.interfaces:
for alt in intf:
if alt.interfaceClass == HID_CLASS and \
alt.interfaceSubClass == HID_SUBCLASS_NO_BOOT and \
alt.interfaceProtocol == HID_PROTOCOL_0:
self.__hid_intf = alt.interfaceNumber
self.__bulkout = 1 self.__bulkout = 1
self.__bulkin = 0x81 self.__bulkin = 0x81
@@ -98,6 +110,8 @@ class gnuk_token(object):
def stop_gnuk(self): def stop_gnuk(self):
self.__devhandle.releaseInterface() self.__devhandle.releaseInterface()
if self.__hid_intf:
self.__devhandle.detachKernelDriver(self.__hid_intf)
self.__devhandle.setConfiguration(0) self.__devhandle.setConfiguration(0)
return return