зеркало из https://github.com/mozilla/pjs.git
Add code to shutdown the PKCS #11 subsystem so NSS can be called to switch profiles.
This commit is contained in:
Родитель
848edbb92c
Коммит
4f926d7877
|
@ -32,7 +32,7 @@
|
|||
* may use your version of this file under either the MPL or the
|
||||
* GPL.
|
||||
*
|
||||
# $Id: nssinit.c,v 1.11 2001-01-26 04:33:45 relyea%netscape.com Exp $
|
||||
# $Id: nssinit.c,v 1.12 2001-02-01 19:09:18 relyea%netscape.com Exp $
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
@ -289,18 +289,16 @@ NSS_Shutdown(void)
|
|||
CERTCertDBHandle *certHandle;
|
||||
SECKEYKeyDBHandle *keyHandle;
|
||||
|
||||
SECMOD_Shutdown();
|
||||
certHandle = CERT_GetDefaultCertDB();
|
||||
if (certHandle)
|
||||
CERT_ClosePermCertDB(certHandle);
|
||||
CERT_SetDefaultCertDB(NULL);
|
||||
|
||||
keyHandle = SECKEY_GetDefaultKeyDB();
|
||||
if (keyHandle)
|
||||
SECKEY_CloseKeyDB(keyHandle);
|
||||
|
||||
/* XXX
|
||||
* This should also close the secmod DB,
|
||||
* but there's no secmod function to close the DB.
|
||||
*/
|
||||
SECKEY_SetDefaultKeyDB(NULL);
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
|
|
@ -116,6 +116,7 @@ SECStatus PK11_ResetToken(PK11SlotInfo *slot, char *sso_pwd);
|
|||
* Manage the built-In Slot Lists
|
||||
************************************************************/
|
||||
SECStatus PK11_InitSlotLists(void);
|
||||
void PK11_DestroySlotLists(void);
|
||||
PK11SlotList *PK11_GetSlotList(CK_MECHANISM_TYPE type);
|
||||
void PK11_LoadSlotList(PK11SlotInfo *slot, PK11PreSlotInfo *psi, int count);
|
||||
void PK11_ClearSlotList(PK11SlotInfo *slot);
|
||||
|
|
|
@ -1125,6 +1125,21 @@ pk11_initSlotList(PK11SlotList *list)
|
|||
list->head = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
pk11_freeSlotList(PK11SlotList *list)
|
||||
{
|
||||
PK11SlotListElement *le, *next ;
|
||||
if (list == NULL) return;
|
||||
|
||||
for (le = list->head ; le; le = next) {
|
||||
next = le->next;
|
||||
pk11_FreeListElement(list,le);
|
||||
}
|
||||
PK11_USE_THREADS(PZ_DestroyLock((PZLock *)(list->lock));)
|
||||
list->lock = NULL;
|
||||
list->head = NULL;
|
||||
}
|
||||
|
||||
/* initialize the system slotlists */
|
||||
SECStatus
|
||||
PK11_InitSlotLists(void)
|
||||
|
@ -1146,6 +1161,26 @@ PK11_InitSlotLists(void)
|
|||
return SECSuccess;
|
||||
}
|
||||
|
||||
void
|
||||
PK11_DestroySlotLists(void)
|
||||
{
|
||||
pk11_freeSlotList(&pk11_desSlotList);
|
||||
pk11_freeSlotList(&pk11_rc4SlotList);
|
||||
pk11_freeSlotList(&pk11_rc2SlotList);
|
||||
pk11_freeSlotList(&pk11_rc5SlotList);
|
||||
pk11_freeSlotList(&pk11_md5SlotList);
|
||||
pk11_freeSlotList(&pk11_md2SlotList);
|
||||
pk11_freeSlotList(&pk11_sha1SlotList);
|
||||
pk11_freeSlotList(&pk11_rsaSlotList);
|
||||
pk11_freeSlotList(&pk11_dsaSlotList);
|
||||
pk11_freeSlotList(&pk11_dhSlotList);
|
||||
pk11_freeSlotList(&pk11_ideaSlotList);
|
||||
pk11_freeSlotList(&pk11_sslSlotList);
|
||||
pk11_freeSlotList(&pk11_tlsSlotList);
|
||||
pk11_freeSlotList(&pk11_randomSlotList);
|
||||
return;
|
||||
}
|
||||
|
||||
/* return a system slot list based on mechanism */
|
||||
PK11SlotList *
|
||||
PK11_GetSlotList(CK_MECHANISM_TYPE type)
|
||||
|
|
|
@ -173,6 +173,23 @@ void SECMOD_init(char *dbname) {
|
|||
moduleLock = SECMOD_NewListLock();
|
||||
}
|
||||
|
||||
|
||||
void SECMOD_Shutdown() {
|
||||
/* destroy the lock */
|
||||
SECMOD_DestroyListLock(moduleLock);
|
||||
moduleLock = NULL;
|
||||
/* free the internal module */
|
||||
SECMOD_DestroyModule(internalModule);
|
||||
internalModule = NULL;
|
||||
/* destroy the list */
|
||||
SECMOD_DestroyModuleList(modules);
|
||||
modules = NULL;
|
||||
|
||||
/* make all the slots and the lists go away */
|
||||
PK11_DestroySlotLists();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* retrieve the internal module
|
||||
*/
|
||||
|
|
|
@ -77,6 +77,7 @@ SEC_BEGIN_PROTOS
|
|||
|
||||
/* protoypes */
|
||||
extern void SECMOD_init(char *dbname);
|
||||
extern void SECMOD_Shutdown(void);
|
||||
extern SECMODModuleList *SECMOD_GetDefaultModuleList(void);
|
||||
extern SECMODListLock *SECMOD_GetDefaultModuleListLock(void);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче