gsd-smartcard doesn't support plug and play
I have a USB Smart Card reader and I noticed that it won't work if I plug it after the login is performed. I tested this in Ubuntu 22.04 that has the patches from !208 (merged) backported.
Output with the Smart Card reader plugged:
$ killall gsd-smartcard; /usr/libexec/gsd-smartcard -v
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.701: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.Generic
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.701: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.WithP11kit
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.701: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.LoadingDriver
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.701: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.WatchingForEvents
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.701: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.ReportingEvents
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.701: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.FindingSmartcard
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.701: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.NoDrivers
(gsd-smartcard:20917): GLib-DEBUG: 16:53:25.705: unsetenv() is not thread-safe and should not be used after threads are created
(gsd-smartcard:20917): GLib-GIO-DEBUG: 16:53:25.706: _g_io_module_get_default: Found default implementation dconf (DConfSettingsBackend) for 'gsettings-backend'
(gsd-smartcard:20917): dconf-DEBUG: 16:53:25.706: watch_fast: "/org/gnome/settings-daemon/peripherals/smartcard/" (establishing: 0, active: 0)
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.707: bus_acquired_cb: acquired bus 0x563ff2944090 for name org.gnome.SettingsDaemon.Smartcard
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.707: taking name org.gnome.SettingsDaemon.Smartcard on session bus
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.707: Service created, getting modules...
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.708: Registered client at path /org/gnome/SessionManager/Client29
(gsd-smartcard:20917): dconf-DEBUG: 16:53:25.709: watch_established: "/org/gnome/settings-daemon/peripherals/smartcard/" (establishing: 1)
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.710: name_acquired_cb: acquired name org.gnome.SettingsDaemon.Smartcard on bus 0x563ff2944090
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.714: Found p11-kit module opensc-pkcs11
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.719: Registering driver OpenSC smartcard framework
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.720: Found p11-kit module p11-kit-trust
(gsd-smartcard:20917): smartcard-plugin-DEBUG: 16:53:25.720: watching for smartcard events
Output with the Smart Card reader unplugged
$ killall gsd-smartcard; /usr/libexec/gsd-smartcard -v
gsd-smartcard: no process found
(gsd-smartcard:20382): smartcard-plugin-DEBUG: 16:51:43.261: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.Generic
(gsd-smartcard:20382): smartcard-plugin-DEBUG: 16:51:43.261: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.WithP11kit
(gsd-smartcard:20382): smartcard-plugin-DEBUG: 16:51:43.261: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.LoadingDriver
(gsd-smartcard:20382): smartcard-plugin-DEBUG: 16:51:43.261: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.WatchingForEvents
(gsd-smartcard:20382): smartcard-plugin-DEBUG: 16:51:43.261: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.ReportingEvents
(gsd-smartcard:20382): smartcard-plugin-DEBUG: 16:51:43.261: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.FindingSmartcard
(gsd-smartcard:20382): smartcard-plugin-DEBUG: 16:51:43.261: GsdSmartcardManagerError: Registering dbus error org.gnome.SettingsDaemon.Smartcard.Manager.Error.NoDrivers
(gsd-smartcard:20382): GLib-DEBUG: 16:51:43.266: unsetenv() is not thread-safe and should not be used after threads are created
(gsd-smartcard:20382): GLib-GIO-DEBUG: 16:51:43.267: _g_io_module_get_default: Found default implementation dconf (DConfSettingsBackend) for 'gsettings-backend'
(gsd-smartcard:20382): dconf-DEBUG: 16:51:43.267: watch_fast: "/org/gnome/settings-daemon/peripherals/smartcard/" (establishing: 0, active: 0)
(gsd-smartcard:20382): smartcard-plugin-DEBUG: 16:51:43.268: bus_acquired_cb: acquired bus 0x55a6e4efd090 for name org.gnome.SettingsDaemon.Smartcard
(gsd-smartcard:20382): smartcard-plugin-DEBUG: 16:51:43.268: taking name org.gnome.SettingsDaemon.Smartcard on session bus
(gsd-smartcard:20382): smartcard-plugin-DEBUG: 16:51:43.268: Service created, getting modules...
(gsd-smartcard:20382): smartcard-plugin-DEBUG: 16:51:43.269: Registered client at path /org/gnome/SessionManager/Client26
(gsd-smartcard:20382): dconf-DEBUG: 16:51:43.270: watch_established: "/org/gnome/settings-daemon/peripherals/smartcard/" (establishing: 1)
(gsd-smartcard:20382): smartcard-plugin-DEBUG: 16:51:43.271: name_acquired_cb: acquired name org.gnome.SettingsDaemon.Smartcard on bus 0x55a6e4efd090
(gsd-smartcard:20382): smartcard-plugin-DEBUG: 16:51:43.272: Found p11-kit module opensc-pkcs11
(gsd-smartcard:20382): smartcard-plugin-DEBUG: 16:51:43.272: Found p11-kit module p11-kit-trust
(gsd-smartcard:20382): smartcard-plugin-DEBUG: 16:51:43.272: Error watching smartcards: No smartcard exist to be activated.
The reason is that once the gck modules are initialized we check if they contain a removable slot. However, the opensc-pkcs11
module won't have any slot at the time of the check. As consequence, the following condition is triggered and we skip the module entirely.
if (!module_has_removable_slot (module))
continue;