Bug 1684945 - [abrt] yubikey-manager: __init__(): PCSCContext.py:40:__init__:smartcard.pcsc.PCSCExceptions.EstablishContextException: 'Failure to establish context: Service not available.'
Summary: [abrt] yubikey-manager: __init__(): PCSCContext.py:40:__init__:smartcard.pcsc...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: yubikey-manager
Version: 30
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Gerald Cox
QA Contact: Fedora Extras Quality Assurance
URL: https://retrace.fedoraproject.org/faf...
Whiteboard: abrt_hash:53718569e207fa1478d7c48eb0a...
Depends On: 1737264
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-03-03 23:57 UTC by Dominik 'Rathann' Mierzejewski
Modified: 2019-11-21 01:24 UTC (History)
2 users (show)

Fixed In Version: yubikey-manager-3.0.0-6.gitcfa1907.fc31 yubikey-manager-3.0.0-6.gitcfa1907.fc30 yubikey-manager-3.0.0-7.git1f22620.fc30 yubikey-manager-3.0.0-7.git1f22620.fc31
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-11-02 02:27:58 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
File: backtrace (2.66 KB, text/plain)
2019-03-03 23:57 UTC, Dominik 'Rathann' Mierzejewski
no flags Details
File: cgroup (341 bytes, text/plain)
2019-03-03 23:57 UTC, Dominik 'Rathann' Mierzejewski
no flags Details
File: cpuinfo (1.27 KB, text/plain)
2019-03-03 23:57 UTC, Dominik 'Rathann' Mierzejewski
no flags Details
File: environ (3.67 KB, text/plain)
2019-03-03 23:57 UTC, Dominik 'Rathann' Mierzejewski
no flags Details
File: mountinfo (3.97 KB, text/plain)
2019-03-03 23:57 UTC, Dominik 'Rathann' Mierzejewski
no flags Details
File: namespaces (129 bytes, text/plain)
2019-03-03 23:57 UTC, Dominik 'Rathann' Mierzejewski
no flags Details
File: open_fds (872 bytes, text/plain)
2019-03-03 23:57 UTC, Dominik 'Rathann' Mierzejewski
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Github Yubico yubikey-manager issues 283 0 'None' 'closed' 'ykman throws exception when pcscd.socket and pcscd.service units stopped' 2019-11-25 11:04:44 UTC

Description Dominik 'Rathann' Mierzejewski 2019-03-03 23:57:20 UTC
Description of problem:
Invoke ykman list with pcscd.service not running.

Version-Release number of selected component:
yubikey-manager-2.0.0-3.gite17b3de.fc29

Additional info:
reporter:       libreport-2.10.0
cmdline:        /usr/bin/python3 /usr/bin/ykman list
crash_function: __init__
exception_type: smartcard.pcsc.PCSCExceptions.EstablishContextException
executable:     /usr/bin/ykman
interpreter:    python3-3.7.2-4.fc29.x86_64
kernel:         4.20.3-200.fc29.x86_64
runlevel:       N 5
type:           Python3
uid:            5242

Truncated backtrace:
PCSCContext.py:40:__init__:smartcard.pcsc.PCSCExceptions.EstablishContextException: 'Failure to establish context: Service not available.'

Traceback (most recent call last):
  File "/usr/bin/ykman", line 11, in <module>
    load_entry_point('yubikey-manager==2.0.0', 'console_scripts', 'ykman')()
  File "/usr/lib/python3.7/site-packages/ykman/cli/__main__.py", line 246, in main
    cli(obj={})
  File "/usr/lib/python3.7/site-packages/click/core.py", line 721, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 1065, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.7/site-packages/click/core.py", line 894, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python3.7/site-packages/ykman/cli/__main__.py", line 206, in list_keys
    for dev in list_devices():
  File "/usr/lib/python3.7/site-packages/ykman/descriptor.py", line 152, in list_devices
    for d in _list_drivers(transports):
  File "/usr/lib/python3.7/site-packages/ykman/descriptor.py", line 138, in _list_drivers
    for dev in open_ccid():
  File "/usr/lib/python3.7/site-packages/ykman/driver_ccid.py", line 322, in open_devices
    readers = _list_readers()
  File "/usr/lib/python3.7/site-packages/ykman/driver_ccid.py", line 312, in _list_readers
    return System.readers()
  File "/usr/lib64/python3.7/site-packages/smartcard/System.py", line 42, in readers
    return smartcard.reader.ReaderFactory.ReaderFactory.readers(groups)
  File "/usr/lib64/python3.7/site-packages/smartcard/reader/ReaderFactory.py", line 58, in readers
    zreaders += fm(groups)
  File "/usr/lib64/python3.7/site-packages/smartcard/pcsc/PCSCReader.py", line 108, in readers
    hcontext = PCSCContext().getContext()
  File "/usr/lib64/python3.7/site-packages/smartcard/pcsc/PCSCContext.py", line 53, in __init__
    PCSCContext.instance = PCSCContext.__PCSCContextSingleton()
  File "/usr/lib64/python3.7/site-packages/smartcard/pcsc/PCSCContext.py", line 40, in __init__
    raise EstablishContextException(hresult)
smartcard.pcsc.PCSCExceptions.EstablishContextException: 'Failure to establish context: Service not available.'

Local variables in innermost frame:
self: <smartcard.pcsc.PCSCContext.PCSCContext.__PCSCContextSingleton object at 0x7f0a40b887b8>
hresult: 2148532253

Comment 1 Dominik 'Rathann' Mierzejewski 2019-03-03 23:57:22 UTC
Created attachment 1540424 [details]
File: backtrace

Comment 2 Dominik 'Rathann' Mierzejewski 2019-03-03 23:57:24 UTC
Created attachment 1540425 [details]
File: cgroup

Comment 3 Dominik 'Rathann' Mierzejewski 2019-03-03 23:57:25 UTC
Created attachment 1540426 [details]
File: cpuinfo

Comment 4 Dominik 'Rathann' Mierzejewski 2019-03-03 23:57:26 UTC
Created attachment 1540427 [details]
File: environ

Comment 5 Dominik 'Rathann' Mierzejewski 2019-03-03 23:57:27 UTC
Created attachment 1540428 [details]
File: mountinfo

Comment 6 Dominik 'Rathann' Mierzejewski 2019-03-03 23:57:28 UTC
Created attachment 1540429 [details]
File: namespaces

Comment 7 Dominik 'Rathann' Mierzejewski 2019-03-03 23:57:29 UTC
Created attachment 1540430 [details]
File: open_fds

Comment 8 Gerald Cox 2019-04-28 19:45:46 UTC
Please test again with yubikey-manager 2.1.0.

I just tested and cannot reproduce.

Comment 9 Dominik 'Rathann' Mierzejewski 2019-10-23 08:36:07 UTC
Still reproducible:
$ rpm -q yubikey-manager
yubikey-manager-2.1.0-2.gitb44d719.fc30.noarch
$ systemctl status pcscd.service pcscd.socket | sed -e 's/sakura.greysector.net/localhost.localdomain/g'
● pcscd.service - PC/SC Smart Card Daemon
   Loaded: loaded (/usr/lib/systemd/system/pcscd.service; indirect; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2019-10-23 10:33:59 CEST; 1min 26s ago
     Docs: man:pcscd(8)
  Process: 1388 ExecStart=/usr/sbin/pcscd --foreground --auto-exit (code=exited, status=1/FAILURE)
 Main PID: 1388 (code=exited, status=1/FAILURE)

Oct 18 11:02:20 localhost.localdomain systemd[1]: Started PC/SC Smart Card Daemon.
Oct 23 10:33:59 localhost.localdomain systemd[1]: Stopping PC/SC Smart Card Daemon...
Oct 23 10:33:59 localhost.localdomain systemd[1]: pcscd.service: Main process exited, code=exited, status=1/FAILURE
Oct 23 10:33:59 localhost.localdomain systemd[1]: pcscd.service: Failed with result 'exit-code'.
Oct 23 10:33:59 localhost.localdomain systemd[1]: Stopped PC/SC Smart Card Daemon.

● pcscd.socket - PC/SC Smart Card Daemon Activation Socket
   Loaded: loaded (/usr/lib/systemd/system/pcscd.socket; enabled; vendor preset: enabled)
   Active: inactive (dead) since Wed 2019-10-23 10:34:02 CEST; 1min 23s ago
   Listen: /var/run/pcscd/pcscd.comm (Stream)

Oct 18 11:02:16 localhost.localdomain systemd[1]: Listening on PC/SC Smart Card Daemon Activation Socket.
Oct 23 10:34:02 localhost.localdomain systemd[1]: pcscd.socket: Succeeded.
Oct 23 10:34:02 localhost.localdomain systemd[1]: Closed PC/SC Smart Card Daemon Activation Socket.
$ ykman list
Traceback (most recent call last):
  File "/usr/bin/ykman", line 11, in <module>
    load_entry_point('yubikey-manager==2.1.0', 'console_scripts', 'ykman')()
  File "/usr/lib/python3.7/site-packages/ykman/cli/__main__.py", line 253, in main
    cli(obj={})
  File "/usr/lib/python3.7/site-packages/click/core.py", line 763, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 716, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 1136, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.7/site-packages/click/core.py", line 955, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.7/site-packages/click/core.py", line 554, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python3.7/site-packages/ykman/cli/__main__.py", line 213, in list_keys
    for dev in list_devices():
  File "/usr/lib/python3.7/site-packages/ykman/descriptor.py", line 152, in list_devices
    for d in _list_drivers(transports):
  File "/usr/lib/python3.7/site-packages/ykman/descriptor.py", line 138, in _list_drivers
    for dev in open_ccid():
  File "/usr/lib/python3.7/site-packages/ykman/driver_ccid.py", line 322, in open_devices
    readers = list_readers()
  File "/usr/lib/python3.7/site-packages/ykman/driver_ccid.py", line 312, in list_readers
    return System.readers()
  File "/usr/lib64/python3.7/site-packages/smartcard/System.py", line 42, in readers
    return smartcard.reader.ReaderFactory.ReaderFactory.readers(groups)
  File "/usr/lib64/python3.7/site-packages/smartcard/reader/ReaderFactory.py", line 58, in readers
    zreaders += fm(groups)
  File "/usr/lib64/python3.7/site-packages/smartcard/pcsc/PCSCReader.py", line 108, in readers
    hcontext = PCSCContext().getContext()
  File "/usr/lib64/python3.7/site-packages/smartcard/pcsc/PCSCContext.py", line 53, in __init__
    PCSCContext.instance = PCSCContext.__PCSCContextSingleton()
  File "/usr/lib64/python3.7/site-packages/smartcard/pcsc/PCSCContext.py", line 40, in __init__
    raise EstablishContextException(hresult)
smartcard.pcsc.PCSCExceptions.EstablishContextException: 'Failure to establish context: Service not available.'

Comment 10 Dominik 'Rathann' Mierzejewski 2019-10-23 08:36:55 UTC
Bumping to F30.

Comment 11 Gerald Cox 2019-10-23 15:10:25 UTC
rpm -qa | grep yubikey-manager
python3-yubikey-manager-3.0.0-2.gitcfa1907.fc30.noarch
yubikey-manager-3.0.0-2.gitcfa1907.fc30.noarch

systemctl stop pcscd.service
Warning: Stopping pcscd.service, but it can still be activated by:
pcscd.socket

ykman list
YubiKey NEO [OTP+FIDO+CCID]

Appears to work with v3.0.0
but unfortunately need python-fido2-0.7.0-1.fc30 and the packager
is having dependency issues for F30

as soon as he upgrades I can push.

Comment 12 Dominik 'Rathann' Mierzejewski 2019-10-24 08:16:19 UTC
Similar problem has been detected:

Stopped pcscd.socket and pcscd.service units. Ran ykman list.

reporter:       libreport-2.10.1
cmdline:        /usr/bin/python3 /usr/bin/ykman list
crash_function: __init__
exception_type: smartcard.pcsc.PCSCExceptions.EstablishContextException
executable:     /usr/bin/ykman
interpreter:    python3-3.7.4-1.fc30.x86_64
kernel:         5.3.6-200.fc30.x86_64
package:        yubikey-manager-2.1.0-2.gitb44d719.fc30
reason:         PCSCContext.py:40:__init__:smartcard.pcsc.PCSCExceptions.EstablishContextException: 'Failure to establish context: Service not available.'
runlevel:       N 5
type:           Python3
uid:            5242

Comment 13 Fedora Update System 2019-10-24 17:20:42 UTC
FEDORA-2019-966121233a has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2019-966121233a

Comment 14 Fedora Update System 2019-10-24 18:55:00 UTC
yubikey-manager-3.0.0-6.gitcfa1907.fc31 has been pushed to the Fedora 31 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-966121233a

Comment 15 Dominik 'Rathann' Mierzejewski 2019-10-24 22:05:07 UTC
(In reply to Gerald Cox from comment #11)
> rpm -qa | grep yubikey-manager
> python3-yubikey-manager-3.0.0-2.gitcfa1907.fc30.noarch
> yubikey-manager-3.0.0-2.gitcfa1907.fc30.noarch
> 
> systemctl stop pcscd.service
> Warning: Stopping pcscd.service, but it can still be activated by:
> pcscd.socket

As the warning says, you need to stop both pcscd.service and pcscd.socket, otherwise it gets started automatically and you cannot trigger the exception.

Comment 16 Gerald Cox 2019-10-25 14:53:12 UTC
(In reply to Dominik 'Rathann' Mierzejewski from comment #15)
> (In reply to Gerald Cox from comment #11)
> > rpm -qa | grep yubikey-manager
> > python3-yubikey-manager-3.0.0-2.gitcfa1907.fc30.noarch
> > yubikey-manager-3.0.0-2.gitcfa1907.fc30.noarch
> > 
> > systemctl stop pcscd.service
> > Warning: Stopping pcscd.service, but it can still be activated by:
> > pcscd.socket
> 
> As the warning says, you need to stop both pcscd.service and pcscd.socket,
> otherwise it gets started automatically and you cannot trigger the exception.

Got it... did a search and found this:
https://github.com/Yubico/yubikey-manager/issues/20

Looks like pscd is required.

Comment 17 Gerald Cox 2019-10-25 17:30:42 UTC
Reported the issue upstream.  You may wish to add additional detail there.

Comment 18 Gerald Cox 2019-10-28 13:29:25 UTC
Response from upstream:
Could you please elaborate a bit more regarding the specific issue? What is the problem and what is the expected behavior? pcscd needs to be running for CCID. That's why you get an exception when running ykman list if pcscd is stopped.

Comment 19 Dominik 'Rathann' Mierzejewski 2019-10-29 12:01:41 UTC
Thanks, Gerald, but there's no need to copy&paste upstream responses here. I'm Cc'd on the upstream issue and will respond there.

Comment 20 Fedora Update System 2019-11-02 02:27:58 UTC
yubikey-manager-3.0.0-6.gitcfa1907.fc31 has been pushed to the Fedora 31 stable repository. If problems still persist, please make note of it in this bug report.

Comment 21 Fedora Update System 2019-11-02 15:04:51 UTC
FEDORA-2019-f6c811e862 has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-f6c811e862

Comment 22 Fedora Update System 2019-11-04 02:09:33 UTC
yubikey-manager-3.0.0-6.gitcfa1907.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-f6c811e862

Comment 23 Fedora Update System 2019-11-11 15:31:28 UTC
FEDORA-2019-e839400498 has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2019-e839400498

Comment 24 Fedora Update System 2019-11-11 15:31:51 UTC
FEDORA-2019-494e3aa88e has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-494e3aa88e

Comment 25 Fedora Update System 2019-11-12 02:08:21 UTC
yubikey-manager-3.0.0-6.gitcfa1907.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.

Comment 26 Fedora Update System 2019-11-12 03:07:58 UTC
yubikey-manager-3.0.0-7.git1f22620.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-494e3aa88e

Comment 27 Fedora Update System 2019-11-13 04:56:30 UTC
yubikey-manager-3.0.0-7.git1f22620.fc31 has been pushed to the Fedora 31 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-e839400498

Comment 28 Fedora Update System 2019-11-20 03:49:40 UTC
yubikey-manager-3.0.0-7.git1f22620.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.

Comment 29 Fedora Update System 2019-11-21 01:24:07 UTC
yubikey-manager-3.0.0-7.git1f22620.fc31 has been pushed to the Fedora 31 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.