From 199b17122d2da46105fcf4d740da4b17e72466d8 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Mon, 19 Jul 2010 15:53:31 +0200 Subject: Do not try to log in if we already have a user session --- src/libstrongswan/plugins/pkcs11/pkcs11_private_key.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_private_key.c b/src/libstrongswan/plugins/pkcs11/pkcs11_private_key.c index fa96c7f22..0f3c4b7ef 100644 --- a/src/libstrongswan/plugins/pkcs11/pkcs11_private_key.c +++ b/src/libstrongswan/plugins/pkcs11/pkcs11_private_key.c @@ -340,8 +340,21 @@ static bool login(private_pkcs11_private_key_t *this, chunk_t keyid, int slot) shared_key_t *shared; chunk_t pin; CK_RV rv; + CK_SESSION_INFO info; bool found = FALSE, success = FALSE; + rv = this->lib->f->C_GetSessionInfo(this->session, &info); + if (rv != CKR_OK) + { + DBG1(DBG_CFG, "C_GetSessionInfo failed: %N", ck_rv_names, rv); + return FALSE; + } + if (info.state != CKS_RO_PUBLIC_SESSION && + info.state != CKS_RW_PUBLIC_SESSION) + { /* already logged in with another session, skip */ + return TRUE; + } + id = identification_create_from_encoding(ID_KEY_ID, keyid); enumerator = lib->credmgr->create_shared_enumerator(lib->credmgr, SHARED_PIN, id, NULL); -- cgit v1.2.3