aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2010-07-19 15:53:31 +0200
committerMartin Willi <martin@revosec.ch>2010-08-04 09:26:21 +0200
commit199b17122d2da46105fcf4d740da4b17e72466d8 (patch)
tree5b6b6dc278ac8e35e6c40d9c01fe7eccbc77659a /src
parent15177f5785bcec6700f2a1a698cd8392c9bba5e9 (diff)
downloadstrongswan-199b17122d2da46105fcf4d740da4b17e72466d8.tar.bz2
strongswan-199b17122d2da46105fcf4d740da4b17e72466d8.tar.xz
Do not try to log in if we already have a user session
Diffstat (limited to 'src')
-rw-r--r--src/libstrongswan/plugins/pkcs11/pkcs11_private_key.c13
1 files changed, 13 insertions, 0 deletions
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);