if (rwsession == CK_INVALID_SESSION) goto done;
if (rwsession == CK_INVALID_SESSION) { PORT_SetError(SEC_ERROR_BAD_DATA); slot->lastLoginCheck = 0; return rv; }
PK11_InitPin(PK11SlotInfo *slot,char *ssopw, char *userpw){    CK_SESSION_HANDLE rwsession = CK_INVALID_SESSION;    CK_RV crv;    SECStatus rv = SECFailure;    int len;    int ssolen;    if (userpw == NULL) userpw = "";    if (ssopw == NULL) ssopw = "";    len = PORT_Strlen(userpw);    ssolen = PORT_Strlen(ssopw);    /* get a rwsession */    rwsession = PK11_GetRWSession(slot);    if (rwsession == CK_INVALID_SESSION) goto done;    if (slot->protectedAuthPath) {	len = 0;	ssolen = 0;	ssopw = NULL;	userpw = NULL;    }    /* check the password */    crv = PK11_GETTAB(slot)->C_Login(rwsession,CKU_SO, 					  (unsigned char *)ssopw,ssolen);    slot->lastLoginCheck = 0;    if (crv != CKR_OK) {	PORT_SetError(PK11_MapError(crv));	goto done;    }    crv = PK11_GETTAB(slot)->C_InitPIN(rwsession,(unsigned char *)userpw,len);    if (crv != CKR_OK) {	PORT_SetError(PK11_MapError(crv));    } else {    	rv = SECSuccess;    }done:    PK11_GETTAB(slot)->C_Logout(rwsession);    slot->lastLoginCheck = 0;    PK11_RestoreROSession(slot,rwsession);    if (rv == SECSuccess) {        /* update our view of the world */        PK11_InitToken(slot,PR_TRUE);	PK11_EnterSlotMonitor(slot);    	PK11_GETTAB(slot)->C_Login(slot->session,CKU_USER,						(unsigned char *)userpw,len);	slot->lastLoginCheck = 0;	PK11_ExitSlotMonitor(slot);    }    return rv;}