#160 Option for the mode_yubikey_otp must be bytes and not string.
Merged 4 years ago by mohanboddu. Opened 4 years ago by cverna.
cverna/fedora-packager yubikey  into  master

file modified
+2 -2
@@ -77,8 +77,8 @@ 

  

  try:

      ykconfig = ykey.init_config()

-     ykconfig.mode_yubikey_otp('h:%s' % opts[1], 'h:%s' % opts[2])

-     ykconfig.fixed_string(str('m:%s' % opts[0]))

+     ykconfig.mode_yubikey_otp(f'h:{opts[1]}'.encode(), f'h:{opts[2]}'.encode())

+     ykconfig.fixed_string(str(f'm:{opts[0]}'))

      ykconfig.ticket_flag('APPEND_CR', True)

      ykconfig.config_flag('STATIC_TICKET', False)

      if ykey.version_num() >= (2, 1):

This yubico library expect these parameters to be bytes
instead of string.

Also replacing the string formating by f-strings.

fixes #158

Signed-off-by: Clement Verna cverna@tutanota.com

There is still a weird exception at the end, but at least we reach the part of the script that writes to the yubi and prints Success! Your Yubikey ID is .........................

Exception ignored in: <function YubiKeyHIDDevice.__del__ at 0x7faf4776d200>
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/yubico/yubikey_usb_hid.py", line 138, in __del__
  File "/usr/lib/python3.7/site-packages/yubico/yubikey_usb_hid.py", line 345, in _close
  File "/usr/lib/python3.7/site-packages/usb/legacy.py", line 235, in releaseInterface
  File "/usr/lib/python3.7/site-packages/usb/util.py", line 217, in release_interface
AttributeError: 'NoneType' object has no attribute '_ctx'

Pull-Request has been merged by mohanboddu

4 years ago
Metadata