[gnome-settings-daemon/rhel-6.9: 12/25] smartcard: allow smartcard slot id to be 0



commit a804043d6a96836332ea21e6bcb02056b1a7beb4
Author: Ray Strode <rstrode redhat com>
Date:   Mon Jan 18 14:49:27 2016 -0500

    smartcard: allow smartcard slot id to be 0
    
    This is required by the specification and some
    PKCS11 modules rely on it working.

 plugins/smartcard/gsd-smartcard.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/plugins/smartcard/gsd-smartcard.c b/plugins/smartcard/gsd-smartcard.c
index d5863c7..548315c 100644
--- a/plugins/smartcard/gsd-smartcard.c
+++ b/plugins/smartcard/gsd-smartcard.c
@@ -39,6 +39,8 @@ struct _GsdSmartcardPrivate {
         GsdSmartcardState state;
 
         CK_SLOT_ID slot_id;
+        guint slot_id_set : 1;
+
         int slot_series;
 
         PK11SlotInfo *slot;
@@ -297,7 +299,7 @@ gsd_smartcard_set_name (GsdSmartcard *card,
                                 int slot_id, slot_series;
 
                                 slot_id = PK11_GetSlotID (card->priv->slot);
-                                if (slot_id != card->priv->slot_id) {
+                                if (!card->priv->slot_id_set || slot_id != card->priv->slot_id) {
                                         gsd_smartcard_set_slot_id (card, slot_id);
                                 }
 
@@ -320,7 +322,7 @@ static void
 gsd_smartcard_set_slot_id (GsdSmartcard *card,
                            int           slot_id)
 {
-        if (card->priv->slot_id != slot_id) {
+        if (!card->priv->slot_id_set || card->priv->slot_id != slot_id) {
                 card->priv->slot_id = slot_id;
 
                 if (card->priv->slot == NULL) {
@@ -344,6 +346,8 @@ gsd_smartcard_set_slot_id (GsdSmartcard *card,
                 }
 
                 g_object_notify (G_OBJECT (card), "slot-id");
+
+                card->priv->slot_id_set = TRUE;
         }
 }
 
@@ -435,7 +439,6 @@ _gsd_smartcard_new (SECMODModule *module,
         GsdSmartcard *card;
 
         g_return_val_if_fail (module != NULL, NULL);
-        g_return_val_if_fail (slot_id >= 1, NULL);
         g_return_val_if_fail (slot_series > 0, NULL);
         g_return_val_if_fail (sizeof (gulong) == sizeof (slot_id), NULL);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]