From 1d07f0835181eaa83859e5ae40928e71c77b81da Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 24 Sep 2015 15:14:45 -0500 Subject: [PATCH] Add ability to specifiy PKCS#11 slot number when using hx509 Example usage: kinit -C PKCS11:/usr/lib/opensc-pkcs11.so,slot=3 foo@BAR.TLD --- lib/hx509/ks_p11.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/hx509/ks_p11.c b/lib/hx509/ks_p11.c index 3a06b015c..12037e6aa 100644 --- a/lib/hx509/ks_p11.c +++ b/lib/hx509/ks_p11.c @@ -65,6 +65,7 @@ struct p11_module { CK_FUNCTION_LIST_PTR funcs; CK_ULONG num_slots; unsigned int ref; + unsigned int selected_slot; struct p11_slot *slot; }; @@ -833,6 +834,7 @@ p11_init(hx509_context context, } p->ref = 1; + p->selected_slot = 0; str = strchr(list, ','); if (str) @@ -842,10 +844,8 @@ p11_init(hx509_context context, strnext = strchr(str, ','); if (strnext) *strnext++ = '\0'; -#if 0 if (strncasecmp(str, "slot=", 5) == 0) p->selected_slot = atoi(str + 5); -#endif str = strnext; } @@ -930,6 +930,8 @@ p11_init(hx509_context context, } for (i = 0; i < p->num_slots; i++) { + if ((p->selected_slot != 0) && (slot_ids[i] != (p->selected_slot - 1))) + continue; ret = p11_init_slot(context, p, lock, slot_ids[i], i, &p->slot[i]); if (!ret) { if (p->slot[i].flags & P11_TOKEN_PRESENT) -- 2.11.4.GIT