Index: cackey.c ================================================================== --- cackey.c +++ cackey.c @@ -2870,20 +2870,18 @@ if (respcode == 0x6982 || respcode == 0x6e00) { CACKEY_DEBUG_PRINTF("Security status not satisified (respcode = 0x%04x). Returning NEEDLOGIN", (int) respcode); cackey_mark_slot_reset(slot); - slot->token_flags = CKF_LOGIN_REQUIRED; return(CACKEY_PCSC_E_NEEDLOGIN); } if (respcode == 0x6E00) { CACKEY_DEBUG_PRINTF("Got \"WRONG CLASS\", this means we are talking to the wrong object (likely because the card went away) -- resetting"); cackey_mark_slot_reset(slot); - slot->token_flags = CKF_LOGIN_REQUIRED; return(CACKEY_PCSC_E_NEEDLOGIN); } if (send_ret == CACKEY_PCSC_E_TOKENABSENT) { @@ -4432,11 +4430,11 @@ CACKEY_DEBUG_PRINTF("Found more readers than slots are available!"); break; } - CACKEY_DEBUG_PRINTF("Found reader: %s", pcsc_readers); + CACKEY_DEBUG_PRINTF("Found reader: %s (currslot = %lu)", pcsc_readers, (unsigned long) currslot); /* Only update the list of slots if we are actually being asked supply the slot information */ if (pSlotList) { if (slot_reset) { cackey_slots[currslot].active = 1; @@ -4449,21 +4447,25 @@ cackey_slots[currslot].label = NULL; cackey_mark_slot_reset(&cackey_slots[currslot]); } } else { - /* Artificially increase the number of active slots by what will become active */ - slot_count++; + if (!cackey_slots[currslot].active) { + /* Artificially increase the number of active slots by what will become active */ + CACKEY_DEBUG_PRINTF("Found in-active slot %lu, but it will be active after a reset -- marking as active for accounting purposes", (unsigned long) currslot); + + slot_count++; + } } currslot++; pcsc_readers += curr_reader_len + 1; } for (currslot = 0; currslot < (sizeof(cackey_slots) / sizeof(cackey_slots[0])); currslot++) { if (cackey_slots[currslot].active) { - CACKEY_DEBUG_PRINTF("Found active slot %lu", (unsigned long) currslot); + CACKEY_DEBUG_PRINTF("Found active slot %lu, reader = %s", (unsigned long) currslot, cackey_slots[currslot].pcsc_reader); slot_count++; } } } else {