Closed Eric8658905 closed 2 years ago
Please describe:
It looks to me like PKCS11_update_slots()
does exactly what it's supposed to do.
Please read: http://catb.org/~esr/faqs/smart-questions.html
1 - detect reader insert/removal 2 - get from enum/update functions results i.e. "slots variable", an updated status about the reader connected or not, if it's not connected it sets to UNAVAILABLE its name if avail. 3 - the "status" result variable keeps all the same values. only works as expected when I plug the reader. even if i call update/enum/release slots ... it won't reflect the reader disconnection. Only way to get some life is to free CTX all the time and it hangs on the next iteration of loop after disconnection.
sometimes I try to give all possible details and cause confusion. I apologize for that.
thank you
Adding to the above (I'm doing more debug as I post here). After it hangs and I plug the reader back, it does detect the slot and get off the hung state, when I remove the reader, it hangs again... some times after one cycle, sometimes a few cycles. As far as I can tell it's hanging on the pkcs11_ctx_unload() inside the "no card if". I have checked all return codes and new_CTX and no problems. when I call the unload of CTX the variable is valid.
libp11 does not support detecting reader insert/removal.
@mtrojnar Ok, lets forget about that then.
1- How can I clear all that is related to p11 operation so I can just reinit all ? I.e. not needing to exit the main(). As far as I can tell calling the unload slots/contexts and assigning NULL should be enough.
2 - if that is the correct procedure, that means I can't unload the context and create it again N times ?
thank you
Hi guys.
I would like to know if this is an issue with the card driver or if I'm doing it wrong.
My goal is to check for card/slot insertion removal, so I'm doing the following.
`#include
include
int main(int argc, char argv[]) { PKCS11_CTX ctx=NULL; PKCS11_SLOT *slots=NULL; unsigned int nslots; int rc = 0;
// ctx = PKCS11_CTX_new(); // rc = PKCS11_CTX_load(ctx, "/usr/lib/libaetpkss.so"); // rc = PKCS11_enumerate_slots(ctx, &slots, &nslots);
} `
It won't clear the slots[0] .... If I remove the reader it won't clear/update, even with assigning NULL as you see. I have first tried with the update function (not releasing the CTX or reloading the module) but If i give the the update function the result of enum (passing the same pckcs11_enum line params), it segfault on me.... if i give it null and 0 it just works but won't reflect the remove/insert of reader.
on this last attempt I'm freeing the context/slots and assigning them null and yet, after it runs the pkcs_update it will set the slot[0].... as if the reader is still connected, i.e. the old values. using this exact sample to replicate that.
am I doing it wrong ? is it an other bug on my card driver ? I would expect it to update the slot[0]. to UNAVAIL...... or is that handled by the card driver ?
best wishes.
PS: forgot to mention, if I free the CTX on the "no slot if", it works for 1 cycle and hangs. i.e. it says "no slot" and hangs there or new/update... didn't have a chance to check.... if not freeing the CTX it won't even budge.