Skip to content

bugfix smartcard polling

This is related to issue #440 (closed).

NSS's SECMOND_WaitForAnyTokenEvent uses the pkcs11 C_WaitForSlotEvent, and by default NSS will use p11-kit, at least on Fedora and Ubuntu. p11-kit doesn't support the blocking call for C_WaitForSlotEvent so NSS falls back to a polling simulation of the C_WaitForSlotEvent. This causes the LED on the smartcard to blink constantly as the card is polled.

If we instead use the non-blocking version of the call, which p11-kit supports, NSS doesn't poll the card. The downside of this is that the application will wake up every second to check for events even if there hasn't been any, plus the fact that there could be up to a second delay between the event and it being picked up by gsd-smartcard. However, NSS is polling anyway so this is consistent with existing behaviour.

The reason a one second delay was chosen was because this is what was currently used in NSS. nss/lib/dev/devslot.c:17

    /* measured in seconds */
    #define NSSSLOT_TOKEN_DELAY_TIME 1

Also included a README as I found it helpful when building the project.

NOTE: This change is based on version 3.30.2 and rebased on master. I wasn't actually able to test on master as I ran into the issue below:

(gsd-smartcard:28935): GLib-GObject-WARNING **: 12:12:37.578: specified class size for type 'GsdSmartcardService' is smaller than the parent type's 'GsdSmartcardServiceManagerSkeleton' class size

(gsd-smartcard:28935): GLib-GObject-CRITICAL **: 12:12:37.578: g_type_add_interface_static: assertion 'G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(gsd-smartcard:28935): GLib-GObject-CRITICAL **: 12:12:37.578: g_type_add_interface_static: assertion 'G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(gsd-smartcard:28935): GLib-CRITICAL **: 12:12:37.578: g_once_init_leave: assertion 'result != 0' failed

(gsd-smartcard:28935): GLib-GIO-CRITICAL **: 12:12:37.578: g_async_initable_new_valist_async: assertion 'G_TYPE_IS_ASYNC_INITABLE (object_type)' failed
Edited by Jack Massey

Merge request reports