Hi Andrew, thanks for you input. And I will gave it a try.
1) deactivated my script 2) added udev rule ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="076b", ATTR{idProduct}=="3022", RUN+="/usr/sbin/service pcscd restart" 3) testdrive - reader unplug - plug in (USB) Jan 06 13:55:00 compd kernel: usb 1-5: USB disconnect, device number 7 Jan 06 13:55:00 compd systemd[1]: smartcard.target: Unit not needed anymore. Stopping. Jan 06 13:55:00 compd systemd[1]: Stopped target Smart Card. Jan 06 13:55:00 compd pcscd[2532]: 99999999 ccid_usb.c:783:WriteUSB() write failed (1/7): -4 LIBUSB_ERROR_NO_DEVICE Jan 06 13:55:03 compd kernel: usb 1-5: new full-speed USB device number 8 using xhci_hcd Jan 06 13:55:03 compd kernel: usb 1-5: New USB device found, idVendor=076b, idProduct=3022 Jan 06 13:55:03 compd kernel: usb 1-5: New USB device strings: Mfr=1, Product=2, SerialNumber=0 Jan 06 13:55:03 compd kernel: usb 1-5: Product: Smart Card Reader USB Jan 06 13:55:03 compd kernel: usb 1-5: Manufacturer: OMNIKEY AG Jan 06 13:55:03 compd mtp-probe[2713]: checking bus 1, device 8: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-5" Jan 06 13:55:03 compd mtp-probe[2713]: bus: 1, device: 8 was not an MTP device Jan 06 13:55:03 compd systemd[1]: Stopping PC/SC Smart Card Daemon... Jan 06 13:55:03 compd systemd[1]: pcscd.service: Main process exited, code=exited, status=1/FAILURE Jan 06 13:55:03 compd systemd[1]: Stopped PC/SC Smart Card Daemon. Jan 06 13:55:03 compd systemd[1]: pcscd.service: Unit entered failed state. Jan 06 13:55:03 compd systemd[1]: pcscd.service: Failed with result 'exit-code'. Jan 06 13:55:03 compd systemd[1]: Started PC/SC Smart Card Daemon. Jan 06 13:55:03 compd systemd[1]: Reached target Smart Card. => works for replugging USB. 4) testrun without unpluging the reader only pulling the card from the reader dirk@compd:~$ gpg --card-status gpg: selecting openpgp failed: No such device gpg: OpenPGP card not available: No such device dirk@compd:~$ gpg --card-status gpg: selecting openpgp failed: No such device gpg: OpenPGP card not available: No such device dirk@compd:~$ gpg --card-status gpg: selecting openpgp failed: No such device gpg: OpenPGP card not available: No such device dirk@compd:~$ gpg --card-status gpg: selecting openpgp failed: Card error gpg: OpenPGP card not available: Card error => no usb activty in syslog =>Failed 5)Works again Your use case was you plugin the usb Card reader with a an ID-1 Card (SIM). I have a fulle sized ID-000 card (Credit Card Size). I never unplug the reader. thanks best regards Dirk On 06.01.2017 12:23, Andrew Gallagher wrote: > On 06/01/17 09:30, Kristian Fiskerstrand wrote: >> On 01/06/2017 10:06 AM, gnupg-users.d...@o.banes.ch wrote: >>> p.s. in the meantime a made a script which tails the scdaemon.log and >>> waits for "Removal of a card:" >>> and then kills the gpg-agent. Not a proper solution - but working so far. >> Why not use udev rule to watch for removal event? > Indeed. > > Dirk, > > I suspect you don't need to kill gpg-agent, just pcscd. I had to do the > same thing when I used an ACS USB reader on my work laptop, because it > already had a built in full-size reader that I couldn't use (I had > already punched out the SIM) but which would override the (removable) > USB reader because it was always found at startup. > > Put the following in /etc/udev/rules.d/99-local.rules (one line) : > > ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="072f", > ATTR{idProduct}=="90cc", RUN+="/usr/sbin/service pcscd restart" > > You will need to change the idVendor and idProduct to match your > hardware - these can be found using `lsusb` while the reader is plugged in. > > A > > > > > _______________________________________________ > Gnupg-users mailing list > Gnupg-users@gnupg.org > http://lists.gnupg.org/mailman/listinfo/gnupg-users _______________________________________________ Gnupg-users mailing list Gnupg-users@gnupg.org http://lists.gnupg.org/mailman/listinfo/gnupg-users