diff options
author | Ray Strode <rstrode@redhat.com> | 2017-02-01 14:42:54 -0500 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2017-02-08 14:23:34 -0500 |
commit | 3aa520c954d3fa6b4da426249c0edb259785ff69 (patch) | |
tree | 6d3906f4dae7583e1d4621a79bc42bcd987a5314 | |
parent | 51242e6159108c8b154ea7bf83eb5937f77bfd79 (diff) | |
download | gnome-settings-daemon-rhel-6.9.tar.gz |
smartcard: manually emit insertion event at startuprhel-6.9
At the moment we rely on getting an insertion event for any already
inserted smartcards at startup time, from NSS. That apparently doesn't
happen for all drivers, though.
This commit changes things up a bit so that we do the insertion event
ourselves, and additionally add some guard code to prevent spurious
insertion events from being emitted.
-rw-r--r-- | plugins/smartcard/gsd-smartcard-manager.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/plugins/smartcard/gsd-smartcard-manager.c b/plugins/smartcard/gsd-smartcard-manager.c index 125d49fd..031ed839 100644 --- a/plugins/smartcard/gsd-smartcard-manager.c +++ b/plugins/smartcard/gsd-smartcard-manager.c @@ -138,6 +138,9 @@ static gboolean read_bytes (int fd, gpointer bytes, gsize num_bytes); static gboolean write_bytes (int fd, gconstpointer bytes, gsize num_bytes); static GsdSmartcard *read_smartcard (int fd, SECMODModule *module); static gboolean write_smartcard (int fd, GsdSmartcard *card); +static gboolean gsd_smartcard_manager_worker_emit_smartcard_inserted (GsdSmartcardManagerWorker *worker, + GsdSmartcard *card, + GError **error); enum { PROP_0 = 0, @@ -856,6 +859,10 @@ gsd_smartcard_manager_get_all_cards (GsdSmartcardManager *manager) g_hash_table_replace (manager->priv->smartcards, card_name, card); + + if (PK11_IsPresent (worker->module->slots[i])) { + gsd_smartcard_manager_worker_emit_smartcard_inserted (worker, card, NULL); + } } node = node->next; } @@ -1306,29 +1313,36 @@ gsd_smartcard_manager_worker_watch_for_and_process_event (GsdSmartcardManagerWor } if (PK11_IsPresent (slot)) { + gboolean already_inserted = FALSE; + /* Now, check to see if their is a new card in the slot. * If there was a different card in the slot now than * there was before, then we need to emit a removed signal * for the old card (we don't want unpaired insertion events). */ - if ((card != NULL) && - card_slot_series != slot_series) { - if (!gsd_smartcard_manager_worker_emit_smartcard_removed (worker, card, &processing_error)) { - g_propagate_error (error, processing_error); - goto out; + if (card != NULL) { + if (card_slot_series != slot_series) { + if (!gsd_smartcard_manager_worker_emit_smartcard_removed (worker, card, &processing_error)) { + g_propagate_error (error, processing_error); + goto out; + } + } else { + already_inserted = TRUE; } } - card = _gsd_smartcard_new (worker->module, - slot_id, slot_series); + if (!already_inserted) { + card = _gsd_smartcard_new (worker->module, + slot_id, slot_series); - g_hash_table_replace (worker->smartcards, - key, card); - key = NULL; + g_hash_table_replace (worker->smartcards, + key, card); + key = NULL; - if (!gsd_smartcard_manager_worker_emit_smartcard_inserted (worker, card, &processing_error)) { - g_propagate_error (error, processing_error); - goto out; + if (!gsd_smartcard_manager_worker_emit_smartcard_inserted (worker, card, &processing_error)) { + g_propagate_error (error, processing_error); + goto out; + } } } else { /* if we aren't tracking the card, just discard the event. |