@gniibe , I was happily running scdaemon 2.1.21-beta73 for more than a month and it properly relinquished the card every time. However, a few days ago it got hold of the card and would not let go (or at least, other users of the card got "sharing violation" error from pcscd). I collected some debugging information:
- Queries
- All Stories
- Search
- Advanced Search
- Transactions
- Transaction Logs
Advanced Search
Jun 1 2017
Apr 16 2017
I can confirm that scdaemon built from today's master (2.1.21-beta73) releases the card, and works as is for my use case.
Version that is included with zesty (2.1.15-1ubuntu7) still keeps the card reserved indefinitely, like all previous versions.
Apr 11 2017
Thank you @gniibe, I will check if scdaemon from 2.1 solves my troubles and followup if it does not.
I could argue that caching the information about the card and reusing it is pointless and dangerous if such cache is not invalidated when the card is removed. Next time the information is needed, there may be a different card lying on the NFC reader. And it certainly does not make sense to keep the card reserved for exclusive use when the card is physically long gone.
Oct 18 2016
A year later on a new computer I had to troubleshoot this problem again, and
found my own bug report. So I am including the patch this time. Please consider
including the proposed change (or some other fix) into mainstream.
Jul 19 2015
Changing PCSC_SHARE_EXCLUSIVE to PCSC_SHARE_SHARED in scd/apdu.c:1560 fixes my
problem *and* has no ill effects on Yubikey operation: gnupg --card-status
interleaved with my application running in a loop at the same time work just
fine, both applications get their proper responses from the card.
This may or may not work with OpenPGP cards other than Yubikey, I have no way to
check...