Fixes for smart card cache. Don't do cache searches by email address, since GetAttributeValue does not set that field. Handle removal correctly for item at tail of list. Don't search token after a successful cache search that returned zero hits.

This commit is contained in:
ian.mcgreer%sun.com 2002-04-19 16:14:13 +00:00
parent 311decf9f8
commit 5377ca2a6c
4 changed files with 39 additions and 22 deletions

View File

@ -35,7 +35,7 @@
#define DEVM_H
#ifdef DEBUG
static const char DEVM_CVS_ID[] = "@(#) $RCSfile: devm.h,v $ $Revision: 1.6 $ $Date: 2002/04/18 17:29:53 $ $Name: $";
static const char DEVM_CVS_ID[] = "@(#) $RCSfile: devm.h,v $ $Revision: 1.7 $ $Date: 2002/04/19 16:14:06 $ $Name: $";
#endif /* DEBUG */
#ifndef BASE_H
@ -171,7 +171,8 @@ nssTokenObjectCache_FindObjectsByTemplate
CK_OBJECT_CLASS objclass,
CK_ATTRIBUTE_PTR otemplate,
CK_ULONG otlen,
PRUint32 maximumOpt
PRUint32 maximumOpt,
PRStatus *statusOpt
);
NSS_EXTERN PRStatus

View File

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: devtoken.c,v $ $Revision: 1.14 $ $Date: 2002/04/18 17:54:30 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: devtoken.c,v $ $Revision: 1.15 $ $Date: 2002/04/19 16:14:06 $ $Name: $";
#endif /* DEBUG */
#ifndef NSSCKEPV_H
@ -488,19 +488,22 @@ find_objects_by_template
if (token->cache &&
nssTokenObjectCache_HaveObjectClass(token->cache, objclass))
{
PRStatus status;
objects = nssTokenObjectCache_FindObjectsByTemplate(token->cache,
objclass,
obj_template,
otsize,
maximumOpt);
if (statusOpt) *statusOpt = PR_SUCCESS;
maximumOpt,
&status);
if (status == PR_SUCCESS) {
if (statusOpt) *statusOpt = status;
return objects;
}
}
/* Either they are not cached, or cache failed; look on token. */
if (!objects) {
objects = find_objects(token, sessionOpt,
obj_template, otsize,
maximumOpt, statusOpt);
}
objects = find_objects(token, sessionOpt,
obj_template, otsize,
maximumOpt, statusOpt);
return objects;
}
@ -670,6 +673,12 @@ nssToken_FindCertificatesByNickname
return objects;
}
/* XXX
* This function *does not* use the token object cache, because not even
* the softoken will return a value for CKA_NETSCAPE_EMAIL from a call
* to GetAttributes. The softoken does allow searches with that attribute,
* it just won't return a value for it.
*/
NSS_IMPLEMENT nssCryptokiObject **
nssToken_FindCertificatesByEmail
(
@ -696,9 +705,9 @@ nssToken_FindCertificatesByEmail
NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_CLASS, &g_ck_class_cert);
NSS_CK_TEMPLATE_FINISH(email_template, attr, etsize);
/* now locate the token certs matching this template */
objects = find_objects_by_template(token, sessionOpt,
email_template, etsize,
maximumOpt, statusOpt);
objects = find_objects(token, sessionOpt,
email_template, etsize,
maximumOpt, statusOpt);
if (!objects) {
/* This is to workaround the fact that PKCS#11 doesn't specify
* whether the '\0' should be included. XXX Is that still true?
@ -707,9 +716,9 @@ nssToken_FindCertificatesByEmail
* well, its needed by the builtin token...
*/
email_template[0].ulValueLen++;
objects = find_objects_by_template(token, sessionOpt,
email_template, etsize,
maximumOpt, statusOpt);
objects = find_objects(token, sessionOpt,
email_template, etsize,
maximumOpt, statusOpt);
}
return objects;
}

View File

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: devutil.c,v $ $Revision: 1.5 $ $Date: 2002/04/18 17:29:55 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: devutil.c,v $ $Revision: 1.6 $ $Date: 2002/04/19 16:14:08 $ $Name: $";
#endif /* DEBUG */
#ifndef DEVM_H
@ -1052,7 +1052,8 @@ nssTokenObjectCache_FindObjectsByTemplate
CK_OBJECT_CLASS objclass,
CK_ATTRIBUTE_PTR otemplate,
CK_ULONG otlen,
PRUint32 maximumOpt
PRUint32 maximumOpt,
PRStatus *statusOpt
)
{
PRStatus status = PR_FAILURE;
@ -1093,6 +1094,9 @@ nssTokenObjectCache_FindObjectsByTemplate
}
finish:
PZ_Unlock(cache->lock);
if (statusOpt) {
*statusOpt = status;
}
return rvObjects;
}
@ -1301,11 +1305,11 @@ nssTokenObjectCache_RemoveObject
break;
}
}
PZ_Unlock(cache->lock);
if (swp && *swp == NULL) {
nss_ZFreeIf(swp); /* the only entry */
if (cache->objects[oType] && cache->objects[oType][0] == NULL) {
nss_ZFreeIf(cache->objects[oType]); /* no entries remaining */
cache->objects[oType] = NULL;
}
PZ_Unlock(cache->lock);
return PR_SUCCESS;
}

View File

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: dev3hack.c,v $ $Revision: 1.12 $ $Date: 2002/04/18 17:29:59 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: dev3hack.c,v $ $Revision: 1.13 $ $Date: 2002/04/19 16:14:13 $ $Name: $";
#endif /* DEBUG */
#ifndef NSS_3_4_CODE
@ -255,6 +255,9 @@ nssSlot_IsLoggedIn
NSSSlot *slot
)
{
if (!slot->pk11slot->needLogin) {
return PR_TRUE;
}
return PK11_IsLoggedIn(slot->pk11slot, NULL);
}