Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applications>PIV tab throws qml: Unmapped error: null __enter__ if pcscd service not running. #343

Open
ipaqmaster opened this issue Mar 20, 2023 · 5 comments

Comments

@ipaqmaster
Copy link

  • YubiKey Manager version: 1.2.5
  • How was it installed?: pacman -S yubikey-manager-qt
  • Operating system and version: Archlinux, Linux 6.2.7-arch1-1
  • YubiKey model and version: Yubikey 5 NFC
  • Bug description summary: If you've just installed this package and have not touched the pcscd service on your machine ever, visiting the Applications > PIV tab results in this GUI experience:

image

Steps to reproduce

[Please explain what you did when the bug appeared, and if and how you have been
able to reproduce it.]

Go to the PIV tab.

Expected result

[What did you expect to happen when you did the above?]

PIV options.

Actual results


[What actually happened?]

Vague general Exception error which doesn't hint at the real and simple solution in any way. Only discovered solution through some online searching.

Other info

[Anything else you would like to add?]

@fdennis
Copy link
Contributor

fdennis commented Mar 22, 2023

I am not able to reproduce on Ubuntu. Could you perhaps launch through the terminal and post the stack trace / exception here? You might have to turn on DEBUG level with the --log-level DEBUG flag at the end. We don't need the whole log, just the stack trace should be enough to help us understand what is going on.

@ipaqmaster
Copy link
Author

Oh, I thought I pasted the stack trace in here already. I've stopped the pcscd service now and got this fresh stacktrace to paste:

PC/SC not available. Smart card (CCID) protocols will not function.
Unable to list devices for connection
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/ykman/device.py", line 287, in list_all_devices
    for dev in _CONNECTION_LIST_MAPPING[connection_type]():
  File "/usr/lib/python3.10/site-packages/ykman/device.py", line 71, in inner
    return f()
  File "/usr/lib/python3.10/site-packages/ykman/device.py", line 88, in list_ccid_devices
    return _list_ccid_devices()
  File "/usr/lib/python3.10/site-packages/ykman/pcsc/__init__.py", line 169, in list_devices
    for reader in list_readers():
  File "/usr/lib/python3.10/site-packages/ykman/pcsc/__init__.py", line 157, in list_readers
    return System.readers()
  File "/usr/lib/python3.10/site-packages/smartcard/System.py", line 41, in readers
    return smartcard.reader.ReaderFactory.ReaderFactory.readers(groups)
  File "/usr/lib/python3.10/site-packages/smartcard/reader/ReaderFactory.py", line 58, in readers
    zreaders += fm(groups)
  File "/usr/lib/python3.10/site-packages/smartcard/pcsc/PCSCReader.py", line 109, in readers
    hcontext = PCSCContext().getContext()
  File "/usr/lib/python3.10/site-packages/smartcard/pcsc/PCSCContext.py", line 56, in __init__
    self.renewContext()
  File "/usr/lib/python3.10/site-packages/smartcard/pcsc/PCSCContext.py", line 70, in renewContext
    PCSCContext.instance = PCSCContext.__PCSCContextSingleton()
  File "/usr/lib/python3.10/site-packages/smartcard/pcsc/PCSCContext.py", line 40, in __init__
    raise EstablishContextException(hresult)
smartcard.pcsc.PCSCExceptions.EstablishContextException: Failed to establish context: Service not available. (0x8010001D)
Uncaught exception
Traceback (most recent call last):
  File "qrc:///py/yubikey.py", line 78, in wrapped
    return f(*args, **kwargs)
  File "qrc:///py/yubikey.py", line 300, in refresh_piv
    with self._open_device([SmartCardConnection]) as conn:
AttributeError: __enter__
qml: Unmapped error: null __enter__

My original provided screeenshot happened again exactly the same.

I am not able to reproduce on Ubuntu

Probably because you did not stop pcscd -- but it is also a testament that the socket may have automatically started it on that distro but doesn't do that on Archlinux. Here it does not start it on its own despite the existence of pcscd.socket --- but also, the GUI error does not accurately describe the issue to the user so it can be fixed manually.

@ipaqmaster
Copy link
Author

To clarify, this seems to be a problem on fresh installs. Ever since I started pcscd myself, the socket seems to be doing its job correctly? But it still doesn't address that the GUI error it throws doesn't help troubleshoot / self-resolve in the slightest.

@fdennis
Copy link
Contributor

fdennis commented Mar 27, 2023

Thanks for the log!

Probably because you did not stop pcscd

I should have been more clear. I meant to say that I cannot reproduce the same error message that you get (Unmapped error: null __enter__) on my Ubuntu machine. I am stopping pcscd but when I press PIV I get the correct error message, which basically explains that it cannot connect to the YubiKey. Perhaps this is not an issue on Ubuntu but is an issue on Arch and/or other distros. I do agree that the GUI error is not that helpful. We will look into this. Thank you!

@ipaqmaster
Copy link
Author

I appreciate your understanding of the issue and a desire to at least make it more clear for the UI.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants