From: Martin Willi Date: Mon, 19 Jul 2010 13:53:31 +0000 (+0200) Subject: Do not try to log in if we already have a user session X-Git-Tag: 4.5.0~593 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=199b17122d2da46105fcf4d740da4b17e72466d8;p=thirdparty%2Fstrongswan.git Do not try to log in if we already have a user session --- diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_private_key.c b/src/libstrongswan/plugins/pkcs11/pkcs11_private_key.c index fa96c7f229..0f3c4b7ef7 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);