Startup problems on new profiles: 1) Windows does not initially open the DB R/W

on startup. 2) All platforms do not see the built-ins token if you startup with
a new profile.

Fix: 1) Escape the initialization parameters.
     2) Rebuild the Token iterator when new tokens are added to the trust domain.
This commit is contained in:
relyea%netscape.com 2002-01-05 03:00:10 +00:00
Родитель 0ff779267a
Коммит dab318ec31
2 изменённых файлов: 40 добавлений и 4 удалений

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: pki3hack.c,v $ $Revision: 1.18 $ $Date: 2002-01-04 19:21:54 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: pki3hack.c,v $ $Revision: 1.19 $ $Date: 2002-01-05 03:00:08 $ $Name: $";
#endif /* DEBUG */
/*
@ -141,10 +141,15 @@ STAN_AddNewSlotToDefaultTD
PK11SlotInfo *sl
)
{
NSSTrustDomain *td =g_default_trust_domain;
NSSToken *token;
token = nssToken_CreateFromPK11SlotInfo(g_default_trust_domain, sl);
token = nssToken_CreateFromPK11SlotInfo(td, sl);
PK11Slot_SetNSSToken(sl, token);
nssList_Add(g_default_trust_domain->tokenList, token);
nssList_Add(td->tokenList, token);
if (td->tokens) {
nssListIterator_Destroy(td->tokens);
}
td->tokens = nssList_CreateIterator(td->tokenList);
return PR_SUCCESS;
}

Просмотреть файл

@ -640,6 +640,33 @@ static void secmod_CloseDB(DB *pkcs11db) {
(*pkcs11db->close)(pkcs11db);
}
static char *
secmod_addEscape(const char *string, char quote)
{
char *newString = 0;
int escapes = 0, size = 0;
const char *src;
char *dest;
for (src=string; *src ; src++) {
if ((*src == quote) || (*src == '\\')) escapes++;
size++;
}
newString = PORT_ZAlloc(escapes+size+1);
if (newString == NULL) {
return NULL;
}
for (src=string, dest=newString; *src; src++,dest++) {
if ((*src == '\\') || (*src == quote)) {
*dest++ = '\\';
}
*dest = *src;
}
return newString;
}
#define SECMOD_STEP 10
#define PK11_DEFAULT_INTERNAL_INIT "library= name=\"NSS Internal PKCS #11 Module\" parameters=\"%s\" NSS=\"Flags=internal,critical slotParams=(1={%s askpw=any timeout=30})\""
@ -688,8 +715,12 @@ secmod_ReadPermDB(char *dbname, char *params, PRBool rw) {
done:
if (!moduleList[0]) {
moduleList[0] = PR_smprintf(PK11_DEFAULT_INTERNAL_INIT,params,
char * newparams = secmod_addEscape(params,'"');
if (newparams) {
moduleList[0] = PR_smprintf(PK11_DEFAULT_INTERNAL_INIT,newparams,
SECMOD_SLOT_FLAGS);
PORT_Free(newparams);
}
}
/* deal with trust cert db here */