LudovicRousseau / PCSC

pcsc-lite: PC/SC implementation
https://pcsclite.apdu.fr/
Other
266 stars 109 forks source link

Yubikey 5 only initialized properly after restarting pcscd #65

Closed flipsa closed 5 years ago

flipsa commented 5 years ago

Hey there,

I got a problem in regards to using a Yubikey 5 NFC for GPG on my Linux system. When I insert the Yubikey:

$ gpg --card-status --expert
gpg: selecting openpgp failed: No such device
gpg: OpenPGP card not available: No such device

I can make it work then by either: i) making sure that pcscd is NOT running (the service starts by itself when inserting the Yubikey even if it was stopped before), or ii) by restarting pcscd. Afterwards the Yubikey is detected without issues, and I can use it as intended.

I searched the issues here (and the web), and my issue is not like #57 as the Yubikey device number changes on removal and re-plugging the Yubikey.

My setup is:

lsusb output (the device number increments fine on removal/reinsertion):

$ lsusb
...
Bus 002 Device 042: ID 1050:0407 Yubico.com Yubikey 4 OTP+U2F+CCID
...

pcscd debug log (:

$ sudo LIBCCID_ifdLogLevel=0x000F pcscd --foreground --debug --apdu --color | tee log.txt
00000000 /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/debuglog.c:299:DebugLogSetLevel() debug level=debug
00000021 /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/debuglog.c:320:DebugLogSetCategory() Debug options: APDU
00000005 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/pcscdaemon.c:352:main() Force colored logs
00000124 [140442152857600] configfile.l:360:DBGetReaderList() Parsing conf file: /etc/reader.conf.d
00000013 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/pcscdaemon.c:662:main() pcsc-lite 1.8.25 daemon ready.
00002103 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0002, path: /dev/bus/usb/001/001
00000131 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0002, path: /dev/bus/usb/001/001
00000103 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x8087, PID: 0x0024, path: /dev/bus/usb/001/002
00000089 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x147E, PID: 0x2016, path: /dev/bus/usb/001/003
00000097 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x8087, PID: 0x0024, path: /dev/bus/usb/001/002
00000086 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x04F2, PID: 0xB221, path: /dev/bus/usb/001/005
00000083 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x04F2, PID: 0xB221, path: /dev/bus/usb/001/005
00000080 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x8087, PID: 0x0024, path: /dev/bus/usb/001/002
00000123 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0002, path: /dev/bus/usb/003/001
00000132 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0003, path: /dev/bus/usb/004/001
00000145 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0002, path: /dev/bus/usb/002/001
00000105 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0002, path: /dev/bus/usb/002/001
00000107 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x8087, PID: 0x0024, path: /dev/bus/usb/002/002
00000110 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x17EF, PID: 0x1003, path: /dev/bus/usb/002/003
00000008 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:440:HPAddDevice() Adding USB device: Lenovo Integrated Smart Card Reader
00000070 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:1074:RFInitializeReader() Attempting startup of Lenovo Integrated Smart Card Reader 00 00 using /usr/lib64/readers/usb/ifd-ccid.bundle/Contents/Linux/libccid.so
00000239 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:950:RFBindFunctions() Loading IFD Handler 3.0
00000027 [140442152857600] ifdhandler.c:1961:init_driver() Driver version: 1.4.30
00000632 [140442152857600] ifdhandler.c:1978:init_driver() LogLevel: 0x0003
00000006 [140442152857600] ifdhandler.c:1989:init_driver() DriverOptions: 0x0000
00000175 [140442152857600] ifdhandler.c:2002:init_driver() LogLevel from LIBCCID_ifdLogLevel: 0x000F
00000006 [140442152857600] ifdhandler.c:110:CreateChannelByNameOrChannel() Lun: 0, device: usb:17ef/1003:libudev:0:/dev/bus/usb/002/003
00000005 [140442152857600] ccid_usb.c:237:OpenUSBByName() Reader index: 0, Device: usb:17ef/1003:libudev:0:/dev/bus/usb/002/003
00000009 [140442152857600] ccid_usb.c:269:OpenUSBByName() interface_number: 0
00000004 [140442152857600] ccid_usb.c:270:OpenUSBByName() usb bus/device: 2/3
00000004 [140442152857600] ccid_usb.c:302:OpenUSBByName() Using: /usr/lib64/readers/usb/ifd-ccid.bundle/Contents/Info.plist
00000586 [140442152857600] ccid_usb.c:320:OpenUSBByName() ifdManufacturerString: Ludovic Rousseau (ludovic.rousseau@free.fr)
00000005 [140442152857600] ccid_usb.c:321:OpenUSBByName() ifdProductString: Generic CCID driver
00000003 [140442152857600] ccid_usb.c:322:OpenUSBByName() Copyright: This driver is protected by terms of the GNU Lesser General Public License version 2.1, or (at your option) any later version.
00001972 [140442152857600] ccid_usb.c:406:OpenUSBByName() Try device: 2/3
00000008 [140442152857600] ccid_usb.c:416:OpenUSBByName() vid/pid : 17EF/1003
00000002 [140442152857600] ccid_usb.c:483:OpenUSBByName() Checking device: 2/3
00000002 [140442152857600] ccid_usb.c:554:OpenUSBByName() Trying to open USB bus/device: 2/3
00111111 [140442152857600] ccid_usb.c:660:OpenUSBByName() Found Vendor/Product: 17EF/1003 (Lenovo Integrated Smart Card Reader)
00000038 [140442152857600] ccid_usb.c:662:OpenUSBByName() Using USB bus/device: 2/3
00000014 [140442152857600] ccid_usb.c:722:OpenUSBByName() bNumDataRatesSupported is 0
00001391 [140442152857600] ccid_usb.c:1306:InterruptRead() before (0)
00007252 [140442152857600] ccid_usb.c:1352:InterruptRead() after (0) (0)
00000118 [140442152857600] NotifySlotChange: 50 02 
00000025 [140442152857600] -> 000000 65 00 00 00 00 00 00 00 00 00 
00000590 [140442152857600] <- 000000 81 00 00 00 00 00 00 02 00 00 
00000031 [140442152857600] -> 000000 65 00 00 00 00 00 01 00 00 00 
00000447 [140442152857600] <- 000000 81 00 00 00 00 00 01 02 00 00 
00000041 [140442152857600] ifdhandler.c:381:IFDHGetCapabilities() tag: 0xFB3, usb:17ef/1003:libudev:0:/dev/bus/usb/002/003 (lun: 0)
00000010 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:396:RFAddReader() Using the reader polling thread
00000008 [140442152857600] ifdhandler.c:1821:IFDHICCPresence() usb:17ef/1003:libudev:0:/dev/bus/usb/002/003 (lun: 0)
00000011 [140442152857600] -> 000000 65 00 00 00 00 00 02 00 00 00 
00000521 [140442152857600] <- 000000 81 00 00 00 00 00 02 02 00 00 
00000019 [140442152857600] ifdhandler.c:1942:IFDHICCPresence() Card absent
00000234 [140442152857600] ifdhandler.c:381:IFDHGetCapabilities() tag: 0xFAE, usb:17ef/1003:libudev:0:/dev/bus/usb/002/003 (lun: 0)
00000021 [140442152857600] ifdhandler.c:476:IFDHGetCapabilities() Reader supports 1 slot(s)
00000041 [140442133612288] ifdhandler.c:1821:IFDHICCPresence() usb:17ef/1003:libudev:0:/dev/bus/usb/002/003 (lun: 0)
00000024 [140442133612288] -> 000000 65 00 00 00 00 00 03 00 00 00 
00000445 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x8087, PID: 0x0024, path: /dev/bus/usb/002/002
00000120 [140442133612288] <- 000000 81 00 00 00 00 00 03 02 00 00 
00000017 [140442133612288] ifdhandler.c:1942:IFDHICCPresence() Card absent
00000017 [140442133612288] ifdhandler.c:1821:IFDHICCPresence() usb:17ef/1003:libudev:0:/dev/bus/usb/002/003 (lun: 0)
00000017 [140442133612288] -> 000000 65 00 00 00 00 00 04 00 00 00 
00000619 [140442133612288] <- 000000 81 00 00 00 00 00 04 02 00 00 
00000029 [140442133612288] ifdhandler.c:1942:IFDHICCPresence() Card absent
00000011 [140442133612288] ifdhandler.c:310:IFDHPolling() usb:17ef/1003:libudev:0:/dev/bus/usb/002/003 (lun: 0) 600000 ms
00000008 [140442133612288] ccid_usb.c:1306:InterruptRead() before (0)

When inserting the Yubikey (debug log from above continued)

10055691 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:655:HPEstablishUSBNotifications() USB Device add
00000179 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x1050, PID: 0x0407, path: /dev/bus/usb/002/044
00000016 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:440:HPAddDevice() Adding USB device: Yubico YubiKey OTP+FIDO+CCID
00000190 [140442125219584] ifdhandler.c:381:IFDHGetCapabilities() tag: 0xFAF, usb:17ef/1003:libudev:0:/dev/bus/usb/002/003 (lun: 0)
00000012 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:726:RFSetReaderName() Support 16 simultaneous readers
00000011 [140442125219584] ifdhandler.c:381:IFDHGetCapabilities() tag: 0xFAD, usb:17ef/1003:libudev:0:/dev/bus/usb/002/003 (lun: 0)
00000005 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:338:RFAddReader() Driver is thread safe
00000006 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:1074:RFInitializeReader() Attempting startup of Yubico YubiKey OTP+FIDO+CCID 01 00 using /usr/lib64/readers/usb/ifd-ccid.bundle/Contents/Linux/libccid.so
00000005 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:863:RFLoadReader() Reusing already loaded driver for /usr/lib64/readers/usb/ifd-ccid.bundle/Contents/Linux/libccid.so
00000016 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:950:RFBindFunctions() Loading IFD Handler 3.0
00000030 [140442125219584] ifdhandler.c:110:CreateChannelByNameOrChannel() Lun: 10000, device: usb:1050/0407:libudev:0:/dev/bus/usb/002/044
00000007 [140442125219584] ccid_usb.c:237:OpenUSBByName() Reader index: 1, Device: usb:1050/0407:libudev:0:/dev/bus/usb/002/044
00000014 [140442125219584] ccid_usb.c:269:OpenUSBByName() interface_number: 0
00000005 [140442125219584] ccid_usb.c:270:OpenUSBByName() usb bus/device: 2/44
00000005 [140442125219584] ccid_usb.c:302:OpenUSBByName() Using: /usr/lib64/readers/usb/ifd-ccid.bundle/Contents/Info.plist
00001475 [140442125219584] ccid_usb.c:320:OpenUSBByName() ifdManufacturerString: Ludovic Rousseau (ludovic.rousseau@free.fr)
00000013 [140442125219584] ccid_usb.c:321:OpenUSBByName() ifdProductString: Generic CCID driver
00000006 [140442125219584] ccid_usb.c:322:OpenUSBByName() Copyright: This driver is protected by terms of the GNU Lesser General Public License version 2.1, or (at your option) any later version.
00000267 [140442125219584] ccid_usb.c:406:OpenUSBByName() Try device: 2/44
00000010 [140442125219584] ccid_usb.c:416:OpenUSBByName() vid/pid : 1050/0407
00000005 [140442125219584] ccid_usb.c:483:OpenUSBByName() Checking device: 2/44
00000003 [140442125219584] ccid_usb.c:554:OpenUSBByName() Trying to open USB bus/device: 2/44
00000105 [140442125219584] ccid_usb.c:637:OpenUSBByName() Found interface 2 but expecting 0
00000005 [140442125219584] ccid_usb.c:639:OpenUSBByName() Wrong interface for USB device 2/44. Checking next one.
00000373 [140442125219584] ccid_usb.c:799:OpenUSBByName() Device not found?
00000008 [140442125219584] ifdhandler.c:150:CreateChannelByNameOrChannel() failed
00000006 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:1105:RFInitializeReader() Open Port 0x200001 Failed (usb:1050/0407:libudev:0:/dev/bus/usb/002/044)
00000004 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:376:RFAddReader() Yubico YubiKey OTP+FIDO+CCID init failed.
00000007 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:610:RFRemoveReader() UnrefReader() count was: 1
00000004 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:1125:RFUnInitializeReader() Attempting shutdown of Yubico YubiKey OTP+FIDO+CCID 01 00.
00000034 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:655:HPEstablishUSBNotifications() USB Device add
00000145 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x1050, PID: 0x0407, path: /dev/bus/usb/002/044
00000008 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:440:HPAddDevice() Adding USB device: Yubico YubiKey OTP+FIDO+CCID
00000109 [140442125219584] ifdhandler.c:381:IFDHGetCapabilities() tag: 0xFAF, usb:17ef/1003:libudev:0:/dev/bus/usb/002/003 (lun: 0)
00000006 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:726:RFSetReaderName() Support 16 simultaneous readers
00000006 [140442125219584] ifdhandler.c:381:IFDHGetCapabilities() tag: 0xFAD, usb:17ef/1003:libudev:0:/dev/bus/usb/002/003 (lun: 0)
00000003 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:338:RFAddReader() Driver is thread safe
00000004 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:1074:RFInitializeReader() Attempting startup of Yubico YubiKey OTP+FIDO+CCID 01 00 using /usr/lib64/readers/usb/ifd-ccid.bundle/Contents/Linux/libccid.so
00000003 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:863:RFLoadReader() Reusing already loaded driver for /usr/lib64/readers/usb/ifd-ccid.bundle/Contents/Linux/libccid.so
00000010 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:950:RFBindFunctions() Loading IFD Handler 3.0
00000020 [140442125219584] ifdhandler.c:110:CreateChannelByNameOrChannel() Lun: 10000, device: usb:1050/0407:libudev:1:/dev/bus/usb/002/044
00000004 [140442125219584] ccid_usb.c:237:OpenUSBByName() Reader index: 1, Device: usb:1050/0407:libudev:1:/dev/bus/usb/002/044
00000008 [140442125219584] ccid_usb.c:269:OpenUSBByName() interface_number: 1
00000003 [140442125219584] ccid_usb.c:270:OpenUSBByName() usb bus/device: 2/44
00000003 [140442125219584] ccid_usb.c:302:OpenUSBByName() Using: /usr/lib64/readers/usb/ifd-ccid.bundle/Contents/Info.plist
00000683 [140442125219584] ccid_usb.c:320:OpenUSBByName() ifdManufacturerString: Ludovic Rousseau (ludovic.rousseau@free.fr)
00000007 [140442125219584] ccid_usb.c:321:OpenUSBByName() ifdProductString: Generic CCID driver
00000004 [140442125219584] ccid_usb.c:322:OpenUSBByName() Copyright: This driver is protected by terms of the GNU Lesser General Public License version 2.1, or (at your option) any later version.
00000273 [140442125219584] ccid_usb.c:406:OpenUSBByName() Try device: 2/44
00000008 [140442125219584] ccid_usb.c:416:OpenUSBByName() vid/pid : 1050/0407
00000004 [140442125219584] ccid_usb.c:483:OpenUSBByName() Checking device: 2/44
00000003 [140442125219584] ccid_usb.c:554:OpenUSBByName() Trying to open USB bus/device: 2/44
00000117 [140442125219584] ccid_usb.c:637:OpenUSBByName() Found interface 2 but expecting 1
00000024 [140442125219584] ccid_usb.c:639:OpenUSBByName() Wrong interface for USB device 2/44. Checking next one.
00000271 [140442125219584] ccid_usb.c:799:OpenUSBByName() Device not found?
00000031 [140442125219584] ifdhandler.c:150:CreateChannelByNameOrChannel() failed
00000020 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:1105:RFInitializeReader() Open Port 0x200001 Failed (usb:1050/0407:libudev:1:/dev/bus/usb/002/044)
00000020 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:376:RFAddReader() Yubico YubiKey OTP+FIDO+CCID init failed.
00000020 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:610:RFRemoveReader() UnrefReader() count was: 1
00000019 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:1125:RFUnInitializeReader() Attempting shutdown of Yubico YubiKey OTP+FIDO+CCID 01 00.
00000050 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:655:HPEstablishUSBNotifications() USB Device add
00000162 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:299:get_driver() Looking for a driver for VID: 0x1050, PID: 0x0407, path: /dev/bus/usb/002/044
00000030 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/hotplug_libudev.c:440:HPAddDevice() Adding USB device: Yubico YubiKey OTP+FIDO+CCID
00000082 [140442125219584] ifdhandler.c:381:IFDHGetCapabilities() tag: 0xFAF, usb:17ef/1003:libudev:0:/dev/bus/usb/002/003 (lun: 0)
00000022 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:726:RFSetReaderName() Support 16 simultaneous readers
00000022 [140442125219584] ifdhandler.c:381:IFDHGetCapabilities() tag: 0xFAD, usb:17ef/1003:libudev:0:/dev/bus/usb/002/003 (lun: 0)
00000020 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:338:RFAddReader() Driver is thread safe
00000019 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:1074:RFInitializeReader() Attempting startup of Yubico YubiKey OTP+FIDO+CCID 01 00 using /usr/lib64/readers/usb/ifd-ccid.bundle/Contents/Linux/libccid.so
00000019 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:863:RFLoadReader() Reusing already loaded driver for /usr/lib64/readers/usb/ifd-ccid.bundle/Contents/Linux/libccid.so
00000027 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:950:RFBindFunctions() Loading IFD Handler 3.0
00000046 [140442125219584] ifdhandler.c:110:CreateChannelByNameOrChannel() Lun: 10000, device: usb:1050/0407:libudev:2:/dev/bus/usb/002/044
00000022 [140442125219584] ccid_usb.c:237:OpenUSBByName() Reader index: 1, Device: usb:1050/0407:libudev:2:/dev/bus/usb/002/044
00000022 [140442125219584] ccid_usb.c:269:OpenUSBByName() interface_number: 2
00000018 [140442125219584] ccid_usb.c:270:OpenUSBByName() usb bus/device: 2/44
00000017 [140442125219584] ccid_usb.c:302:OpenUSBByName() Using: /usr/lib64/readers/usb/ifd-ccid.bundle/Contents/Info.plist
00000695 [140442125219584] ccid_usb.c:320:OpenUSBByName() ifdManufacturerString: Ludovic Rousseau (ludovic.rousseau@free.fr)
00000042 [140442125219584] ccid_usb.c:321:OpenUSBByName() ifdProductString: Generic CCID driver
00000020 [140442125219584] ccid_usb.c:322:OpenUSBByName() Copyright: This driver is protected by terms of the GNU Lesser General Public License version 2.1, or (at your option) any later version.
00000172 [140442125219584] ccid_usb.c:406:OpenUSBByName() Try device: 2/44
00000024 [140442125219584] ccid_usb.c:416:OpenUSBByName() vid/pid : 1050/0407
00000015 [140442125219584] ccid_usb.c:483:OpenUSBByName() Checking device: 2/44
00000015 [140442125219584] ccid_usb.c:554:OpenUSBByName() Trying to open USB bus/device: 2/44
00000160 [140442125219584] ccid_usb.c:660:OpenUSBByName() Found Vendor/Product: 1050/0407 (Yubico YubiKey OTP+FIDO+CCID)
00000024 [140442125219584] ccid_usb.c:662:OpenUSBByName() Using USB bus/device: 2/44
00000018 [140442125219584] ccid_usb.c:722:OpenUSBByName() bNumDataRatesSupported is 0
00001365 [140442125219584] ccid_usb.c:1306:InterruptRead() before (1)
00029202 [140442125219584] ccid_usb.c:1352:InterruptRead() after (1) (0)
00000012 [140442125219584] NotifySlotChange: 50 03 
00000009 [140442125219584] -> 000001 65 00 00 00 00 00 00 00 00 00 
00000348 [140442125219584] <- 000001 81 00 00 00 00 00 00 00 00 00 
00000011 [140442125219584] -> 000001 65 00 00 00 00 00 01 00 00 00 
00000247 [140442125219584] <- 000001 81 00 00 00 00 00 01 00 00 00 
00000009 [140442125219584] ifdhandler.c:381:IFDHGetCapabilities() tag: 0xFB3, usb:1050/0407:libudev:2:/dev/bus/usb/002/044 (lun: 10000)
00000005 [140442125219584] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:396:RFAddReader() Using the reader polling thread
00000004 [140442125219584] ifdhandler.c:1821:IFDHICCPresence() usb:1050/0407:libudev:2:/dev/bus/usb/002/044 (lun: 10000)
00000006 [140442125219584] -> 000001 65 00 00 00 00 00 02 00 00 00 
00000451 [140442125219584] <- 000001 81 00 00 00 00 00 02 00 00 00 
00000009 [140442125219584] ifdhandler.c:1942:IFDHICCPresence() Card present
00000053 [140442125219584] ifdhandler.c:381:IFDHGetCapabilities() tag: 0xFAE, usb:1050/0407:libudev:2:/dev/bus/usb/002/044 (lun: 10000)
00000007 [140442125219584] ifdhandler.c:476:IFDHGetCapabilities() Reader supports 1 slot(s)
00000056 [140442116826880] ifdhandler.c:1821:IFDHICCPresence() usb:1050/0407:libudev:2:/dev/bus/usb/002/044 (lun: 10000)
00000008 [140442116826880] -> 000001 65 00 00 00 00 00 03 00 00 00 
00000362 [140442116826880] <- 000001 81 00 00 00 00 00 03 00 00 00 
00000007 [140442116826880] ifdhandler.c:1942:IFDHICCPresence() Card present
00000004 [140442116826880] ifdhandler.c:1821:IFDHICCPresence() usb:1050/0407:libudev:2:/dev/bus/usb/002/044 (lun: 10000)
00000006 [140442116826880] -> 000001 65 00 00 00 00 00 04 00 00 00 
00000231 [140442116826880] <- 000001 81 00 00 00 00 00 04 00 00 00 
00000007 [140442116826880] ifdhandler.c:1942:IFDHICCPresence() Card present
00000004 [140442116826880] ifdhandler.c:1154:IFDHPowerICC() action: PowerUp, usb:1050/0407:libudev:2:/dev/bus/usb/002/044 (lun: 10000)
00000007 [140442116826880] -> 000001 62 00 00 00 00 00 05 00 00 00 
00000910 [140442116826880] <- 000001 80 17 00 00 00 00 05 00 00 00 3B FD 13 00 00 81 31 FE 15 80 73 C0 21 C0 57 59 75 62 69 4B 65 79 40 
00000055 [140442116826880] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/eventhandler.c:289:EHStatusHandlerThread() powerState: POWER_STATE_POWERED
00000027 [140442116826880] Card ATR: 3B FD 13 00 00 81 31 FE 15 80 73 C0 21 C0 57 59 75 62 69 4B 65 79 40 
00000022 [140442116826880] ifdhandler.c:1821:IFDHICCPresence() usb:1050/0407:libudev:2:/dev/bus/usb/002/044 (lun: 10000)
00000021 [140442116826880] -> 000001 65 00 00 00 00 00 06 00 00 00 
00001488 [140442116826880] <- 000001 81 00 00 00 00 00 06 00 00 00 
00000014 [140442116826880] ifdhandler.c:1942:IFDHICCPresence() Card present
00000004 [140442116826880] ifdhandler.c:310:IFDHPolling() usb:1050/0407:libudev:2:/dev/bus/usb/002/044 (lun: 10000) 5000 ms
00000004 [140442116826880] ccid_usb.c:1306:InterruptRead() before (1)
05001749 [140442116826880] ccid_usb.c:1352:InterruptRead() after (1) (2)
00000056 [140442116826880] ifdhandler.c:1821:IFDHICCPresence() usb:1050/0407:libudev:2:/dev/bus/usb/002/044 (lun: 10000)
00000024 [140442116826880] -> 000001 65 00 00 00 00 00 07 00 00 00 
00000913 [140442116826880] <- 000001 81 00 00 00 00 00 07 00 00 00 
00000037 [140442116826880] ifdhandler.c:1942:IFDHICCPresence() Card present
00000019 [140442116826880] ifdhandler.c:1154:IFDHPowerICC() action: PowerDown, usb:1050/0407:libudev:2:/dev/bus/usb/002/044 (lun: 10000)
00000022 [140442116826880] -> 000001 63 00 00 00 00 00 08 00 00 00 
00000590 [140442116826880] <- 000001 81 00 00 00 00 00 08 02 00 00 
00000031 [140442116826880] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/eventhandler.c:482:EHStatusHandlerThread() powerState: POWER_STATE_UNPOWERED
00000011 [140442116826880] ifdhandler.c:1821:IFDHICCPresence() usb:1050/0407:libudev:2:/dev/bus/usb/002/044 (lun: 10000)
00000012 [140442116826880] -> 000001 65 00 00 00 00 00 09 00 00 00 
00000748 [140442116826880] <- 000001 81 00 00 00 00 00 09 00 00 00 
00000029 [140442116826880] ifdhandler.c:1942:IFDHICCPresence() Card present
00000012 [140442116826880] ifdhandler.c:310:IFDHPolling() usb:1050/0407:libudev:2:/dev/bus/usb/002/044 (lun: 10000) 600000 ms
00000008 [140442116826880] ccid_usb.c:1306:InterruptRead() before (1)

Now trying "gpg --card-status --expert" in another terminal (debug log from above continued):

06208359 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_msg_srv.c:255:ProcessEventsServer() Common channel packet arrival
00000021 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_msg_srv.c:266:ProcessEventsServer() ProcessCommonChannelRequest detects: 15
00000003 [140442152857600] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/pcscdaemon.c:133:SVCServiceRunLoop() A new context thread creation is requested: 15
00017326 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_svc.c:340:ContextThread() Authorized PC/SC client
00000018 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_svc.c:343:ContextThread() Thread is started: dwClientID=15, threadContext @0x55b05132c2a0
00000020 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_svc.c:361:ContextThread() Received command: CMD_VERSION from client 15
00000012 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_svc.c:373:ContextThread() Client is protocol version 4:4
00000006 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_svc.c:394:ContextThread() CMD_VERSION rv=0x0 for client 15
00000062 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_svc.c:361:ContextThread() Received command: ESTABLISH_CONTEXT from client 15
00000014 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard.c:215:SCardEstablishContext() Establishing Context: 0x542E292F
00000004 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_svc.c:459:ContextThread() ESTABLISH_CONTEXT rv=0x0 for client 15
00000034 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_svc.c:361:ContextThread() Received command: CMD_GET_READERS_STATE from client 15
00000050 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_svc.c:361:ContextThread() Received command: CMD_GET_READERS_STATE from client 15
00000108 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_svc.c:361:ContextThread() Received command: CONNECT from client 15
00016267 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/auth.c:135:IsClientAuthorized() Process 1837 (user: 1001) is NOT authorized for action: access_card
00000152 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_svc.c:492:ContextThread() Rejected unauthorized client for 'Lenovo Integrated Smart Card Reader 00 00'
00000019 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard.c:229:SCardReleaseContext() Releasing Context: 0x542E292F
00000007 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_svc.c:1053:MSGCleanupClient() Thread is stopping: dwClientID=15, threadContext @0x55b05132c2a0
00000004 [140442108434176] /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_svc.c:1061:MSGCleanupClient() Freeing SCONTEXT @0x55b05132c2a0

The same experiment, as logged by syslog: pcscd is running, then I insert the Yubikey, then I restart pcscd; after this, the key works fine without any other action (I don't know how to do this with the debug output on as above):

Jun 24 15:21:13 tp kernel: usb 2-1.2: new full-speed USB device number 45 using ehci-pci
Jun 24 15:21:14 tp kernel: usb 2-1.2: New USB device found, idVendor=1050, idProduct=0407, bcdDevice= 5.12
Jun 24 15:21:14 tp kernel: usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Jun 24 15:21:14 tp kernel: usb 2-1.2: Product: YubiKey OTP+FIDO+CCID
Jun 24 15:21:14 tp kernel: usb 2-1.2: Manufacturer: Yubico
Jun 24 15:21:14 tp kernel: input: Yubico YubiKey OTP+FIDO+CCID as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/0003:1050:0407.0085/input/input103
Jun 24 15:21:14 tp kernel: hid-generic 0003:1050:0407.0085: input,hidraw0: USB HID v1.10 Keyboard [Yubico YubiKey OTP+FIDO+CCID] on usb-0000:00:1d.0-1.2/input0
Jun 24 15:21:14 tp kernel: hid-generic 0003:1050:0407.0086: hiddev96,hidraw1: USB HID v1.10 Device [Yubico YubiKey OTP+FIDO+CCID] on usb-0000:00:1d.0-1.2/input1
Jun 24 15:21:14 tp mtp-probe[6041]: checking bus 2, device 45: "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2"
Jun 24 15:21:14 tp mtp-probe[6041]: bus: 2, device: 45 was not an MTP device
Jun 24 15:21:14 tp start-stop-daemon[6106]: pam_unix(start-stop-daemon:session): session opened for user pcscd by (uid=0)
Jun 24 15:21:14 tp pcscd[6107]: ifdhandler.c:150:CreateChannelByNameOrChannel() failed
Jun 24 15:21:14 tp pcscd[6107]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:1105:RFInitializeReader() Open Port 0x200000 Failed (usb:1050/0407:libudev:0:/dev/bus/usb/002/045)
Jun 24 15:21:14 tp pcscd[6107]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:376:RFAddReader() Yubico YubiKey OTP+FIDO+CCID init failed.
Jun 24 15:21:14 tp pcscd[6107]: ifdhandler.c:150:CreateChannelByNameOrChannel() failed
Jun 24 15:21:14 tp pcscd[6107]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:1105:RFInitializeReader() Open Port 0x200000 Failed (usb:1050/0407:libudev:1:/dev/bus/usb/002/045)
Jun 24 15:21:14 tp pcscd[6107]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:376:RFAddReader() Yubico YubiKey OTP+FIDO+CCID init failed.
Jun 24 15:21:14 tp pcscd[6107]: ifdhandler.c:150:CreateChannelByNameOrChannel() failed
Jun 24 15:21:14 tp pcscd[6107]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:1105:RFInitializeReader() Open Port 0x200002 Failed (usb:1050/0407:libudev:1:/dev/bus/usb/002/045)
Jun 24 15:21:14 tp pcscd[6107]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:376:RFAddReader() Yubico YubiKey OTP+FIDO+CCID init failed.
Jun 24 15:21:14 tp pcscd[6107]: ifdhandler.c:150:CreateChannelByNameOrChannel() failed
Jun 24 15:21:14 tp pcscd[6107]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:1105:RFInitializeReader() Open Port 0x200002 Failed (usb:1050/0407:libudev:0:/dev/bus/usb/002/045)
Jun 24 15:21:14 tp pcscd[6107]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:376:RFAddReader() Yubico YubiKey OTP+FIDO+CCID init failed.
Jun 24 15:21:14 tp mtp-probe[6140]: checking bus 2, device 45: "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2"
Jun 24 15:21:14 tp mtp-probe[6140]: bus: 2, device: 45 was not an MTP device

Trying gpg --card-status --expert (in another terminal):

Jun 24 15:21:27 tp polkitd[6599]: /etc/polkit-1/rules.d/00-log-access.rules:2: action=[Action id='org.debian.pcsc-lite.access_pcsc']
Jun 24 15:21:27 tp polkitd[6599]: /etc/polkit-1/rules.d/00-log-access.rules:3: subject=[Subject pid=1837 user='<MYUSERACCOUNT>' groups=<MYUSERACCOUNT>,tty,disk,lp,wheel,floppy,uucp,audio,cdrom,video,cdrw,usb,users,lpadmin,games,clamav,scanner,gkrellmd,vlock,snort,tcpdump,wireshark,plugdev,partimag,polkituser,pulse-access,pulse,pcscd,vboxguest,kismet,vboxusers,bumblebee,android,fingerprint,davfs2 seat=null session='29' local=false active=true]
Jun 24 15:21:27 tp polkitd[6599]: /etc/polkit-1/rules.d/00-log-access.rules:2: action=[Action id='org.debian.pcsc-lite.access_card' reader='Yubico YubiKey OTP+FIDO+CCID 00 00']
Jun 24 15:21:27 tp polkitd[6599]: /etc/polkit-1/rules.d/00-log-access.rules:3: subject=[Subject pid=1837 user='<MYUSERACCOUNT>' groups=<MYUSERACCOUNT>,tty,disk,lp,wheel,floppy,uucp,audio,cdrom,video,cdrw,usb,users,lpadmin,games,clamav,scanner,gkrellmd,vlock,snort,tcpdump,wireshark,plugdev,partimag,polkituser,pulse-access,pulse,pcscd,vboxguest,kismet,vboxusers,bumblebee,android,fingerprint,davfs2 seat=null session='29' local=false active=true]
Jun 24 15:21:27 tp pcscd[6107]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/auth.c:135:IsClientAuthorized() Process 1837 (user: 1001) is NOT authorized for action: access_card
Jun 24 15:21:27 tp pcscd[6107]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/winscard_svc.c:492:ContextThread() Rejected unauthorized client for 'Yubico YubiKey OTP+FIDO+CCID 00 00'

Restarting pcscd:

Jun 24 15:21:35 tp start-stop-daemon[6270]: Will stop /usr/sbin/pcscd
Jun 24 15:21:35 tp start-stop-daemon[6270]: Will stop PID 6107
Jun 24 15:21:35 tp start-stop-daemon[6270]: Sending signal 15 to PID 6107
Jun 24 15:21:35 tp start-stop-daemon[6321]: pam_unix(start-stop-daemon:session): session opened for user pcscd by (uid=0)
Jun 24 15:21:35 tp pcscd[6322]: ccid_usb.c:560:OpenUSBByName() Can't libusb_open(2/45): LIBUSB_ERROR_ACCESS
Jun 24 15:21:35 tp pcscd[6322]: ifdhandler.c:150:CreateChannelByNameOrChannel() failed
Jun 24 15:21:35 tp pcscd[6322]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:1105:RFInitializeReader() Open Port 0x200000 Failed (usb:1050/0407:libudev:0:/dev/bus/usb/002/045)
Jun 24 15:21:35 tp pcscd[6322]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:376:RFAddReader() Yubico YubiKey OTP+FIDO+CCID init failed.
Jun 24 15:21:35 tp pcscd[6322]: ccid_usb.c:560:OpenUSBByName() Can't libusb_open(2/45): LIBUSB_ERROR_ACCESS
Jun 24 15:21:35 tp pcscd[6322]: ifdhandler.c:150:CreateChannelByNameOrChannel() failed
Jun 24 15:21:35 tp pcscd[6322]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:1105:RFInitializeReader() Open Port 0x200000 Failed (usb:1050/0407:libudev:1:/dev/bus/usb/002/045)
Jun 24 15:21:35 tp pcscd[6322]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:376:RFAddReader() Yubico YubiKey OTP+FIDO+CCID init failed.
Jun 24 15:21:35 tp pcscd[6322]: ccid_usb.c:560:OpenUSBByName() Can't libusb_open(2/45): LIBUSB_ERROR_ACCESS
Jun 24 15:21:35 tp pcscd[6322]: ifdhandler.c:150:CreateChannelByNameOrChannel() failed
Jun 24 15:21:35 tp pcscd[6322]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:1105:RFInitializeReader() Open Port 0x200000 Failed (usb:1050/0407:libudev:2:/dev/bus/usb/002/045)
Jun 24 15:21:35 tp pcscd[6322]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/readerfactory.c:376:RFAddReader() Yubico YubiKey OTP+FIDO+CCID init failed.

gpg --card-status --expert (in another terminal):

gpg-agent[1744]: card has S/N: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Let me know if you need more information.

And of course thank your very much for your software and help, it's much appreciated!

LudovicRousseau commented 5 years ago

Your problem seems to be:

Jun 24 15:21:27 tp pcscd[6107]: /var/tmp/portage/sys-apps/pcsc-lite-1.8.25/work/pcsc-lite-1.8.25/src/auth.c:135:IsClientAuthorized() Process 1837 (user: 1001) is NOT authorized for action: access_card

See https://github.com/LudovicRousseau/PCSC/blob/master/doc/README.polkit

flipsa commented 5 years ago

Thanks for the quick answer!

I saw that line in the logs, too, but I didn't think that this was my problem, since everything does work absolutely fine if I either restart or stop the pcscd service and hence ruled out any permission problems.

But to be absolutely sure I just added the polkit rules and got rid of the "not authorized" error above, but the original problem still persists.

LudovicRousseau commented 5 years ago

gpg --card-status works fine if pcscd is NOT running?

flipsa commented 5 years ago

gpg --card-status works fine if pcscd is NOT running?

Yes, if I stop pcscd and then run gpg --card-status, it works. Alternatively I can also restart pcscd and it also works. But as soon as I pull the Yubikey and then re-insert it, gpg --card-status will fail. I noticed pcscd gets started automatically when I insert the Yubikey, but somehow it does not manage to put the Yubikey in a working state. However, both stopping or restarting pcscd will make the Yubikey accessible and working fine. I know it's weird, but it is what I'm seeing here.

One thought I had: do you think it's possible that gpg (or pcscd) somehow get "confused" by the built-in smart card reader while the Yubikey is still in limbo / initializing?

LudovicRousseau commented 5 years ago

I wrote an new article about this FAQ. See https://ludovicrousseau.blogspot.com/2019/06/gnupg-and-pcsc-conflicts.html

Does the proposed solution work for you?

flipsa commented 5 years ago

Hello Ludovic,

Thanks for writing that FAQ, it all makes perfect sense now. The 2nd solution works for me (disable-ccid in ~/.gnupg/scdaemon.conf). Getting rid of pcscd altogher wasn't possible for me, since I need it for other things as well.

Closing this as solved. Thank you very much!