Skip to content

Commit c2e00e9

Browse files
fabledJakuje
authored andcommitted
pkcs11-session: fix C_GetSessionInfo in 'atomic' mode
The device is always in logged-out mode with PIN cached, so ignore the logged-in check. Since the token is now guaranteed to be logged-in or have sessions removed, simplify the further checks to match the session state. Fixes: 4bd8cda "pkcs11-session: When we notice logout in lower layers..."
1 parent b349ad5 commit c2e00e9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/pkcs11/pkcs11-session.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ CK_RV C_GetSessionInfo(CK_SESSION_HANDLE hSession, /* the session's handle */
252252
CK_RV rv;
253253
struct sc_pkcs11_session *session;
254254
struct sc_pkcs11_slot *slot;
255-
int logged_out;
256255
const char *name;
257256

258257
if (pInfo == NULL_PTR)
@@ -276,16 +275,16 @@ CK_RV C_GetSessionInfo(CK_SESSION_HANDLE hSession, /* the session's handle */
276275
pInfo->ulDeviceError = 0;
277276

278277
slot = session->slot;
279-
logged_out = (slot_get_logged_in_state(slot) == SC_PIN_STATE_LOGGED_OUT);
280-
if (logged_out && slot->login_user >= 0) {
278+
if (!sc_pkcs11_conf.atomic && slot->login_user >= 0 &&
279+
slot_get_logged_in_state(slot) == SC_PIN_STATE_LOGGED_OUT) {
281280
slot->login_user = -1;
282281
sc_pkcs11_close_all_sessions(session->slot->id);
283282
rv = CKR_SESSION_HANDLE_INVALID;
284283
goto out;
285284
}
286-
if (slot->login_user == CKU_SO && !logged_out) {
285+
if (slot->login_user == CKU_SO) {
287286
pInfo->state = CKS_RW_SO_FUNCTIONS;
288-
} else if ((slot->login_user == CKU_USER && !logged_out) || (!(slot->token_info.flags & CKF_LOGIN_REQUIRED))) {
287+
} else if (slot->login_user == CKU_USER || !(slot->token_info.flags & CKF_LOGIN_REQUIRED)) {
289288
pInfo->state = (session->flags & CKF_RW_SESSION)
290289
? CKS_RW_USER_FUNCTIONS : CKS_RO_USER_FUNCTIONS;
291290
} else {

0 commit comments

Comments
 (0)