From 4e85b7019a83ca4e178bf067c3925bc36eefc35f Mon Sep 17 00:00:00 2001 From: "javi%netscape.com" Date: Thu, 8 Feb 2001 23:43:00 +0000 Subject: [PATCH] Fix for Bug 68063 r=nelsonb, a=wtc Make NSS_Init backwards compatible for the Mac. --- security/nss/lib/nss/nssinit.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/security/nss/lib/nss/nssinit.c b/security/nss/lib/nss/nssinit.c index c8f617e96ec1..4c43b5d8f44b 100644 --- a/security/nss/lib/nss/nssinit.c +++ b/security/nss/lib/nss/nssinit.c @@ -32,7 +32,7 @@ * may use your version of this file under either the MPL or the * GPL. * - # $Id: nssinit.c,v 1.13 2001/02/04 05:52:42 wtc%netscape.com Exp $ + # $Id: nssinit.c,v 1.14 2001/02/08 23:43:00 javi%netscape.com Exp $ */ #include @@ -51,7 +51,17 @@ #include "cdbhdl.h" /* ??? */ #include "pk11func.h" - +#ifdef macintosh +#define PATH_SEPARATOR ":" +#define SECMOD_DB "Security Modules" +#define CERT_DB_FMT "%sCertificates%s" +#define KEY_DB_FMT "%sKey Database%s" +#else +#define PATH_SEPARATOR "/" +#define SECMOD_DB "secmod.db" +#define CERT_DB_FMT "%scert%s.db" +#define KEY_DB_FMT "%skey%s.db" +#endif static char * nss_certdb_name_cb(void *arg, int dbVersion) @@ -75,7 +85,7 @@ nss_certdb_name_cb(void *arg, int dbVersion) break; } - return PR_smprintf("%scert%s.db", configdir, dbver); + return PR_smprintf(CERT_DB_FMT, configdir, dbver); } static char * @@ -94,7 +104,7 @@ nss_keydb_name_cb(void *arg, int dbVersion) break; } - return PR_smprintf("%skey%s.db", configdir, dbver); + return PR_smprintf(KEY_DB_FMT, configdir, dbver); } static SECStatus @@ -108,7 +118,7 @@ nss_OpenCertDB(const char * configdir, const char *prefix, PRBool readOnly) if (certdb) return SECSuccess; /* idempotency */ - name = PR_smprintf("%s/%s",configdir,prefix); + name = PR_smprintf("%s" PATH_SEPARATOR "%s",configdir,prefix); if (name == NULL) goto loser; certdb = (CERTCertDBHandle*)PORT_ZAlloc(sizeof(CERTCertDBHandle)); @@ -136,7 +146,7 @@ nss_OpenKeyDB(const char * configdir, const char *prefix, PRBool readOnly) keydb = SECKEY_GetDefaultKeyDB(); if (keydb) return SECSuccess; - name = PR_smprintf("%s/%s",configdir,prefix); + name = PR_smprintf("%s" PATH_SEPARATOR "%s",configdir,prefix); if (name == NULL) return SECFailure; keydb = SECKEY_OpenKeyDB(readOnly, nss_keydb_name_cb, (void *)name); @@ -157,7 +167,7 @@ nss_OpenSecModDB(const char * configdir,const char *dbname) */ if (secmodname) return SECSuccess; - secmodname = PR_smprintf("%s/%s", configdir,dbname); + secmodname = PR_smprintf("%s" PATH_SEPARATOR "%s", configdir,dbname); if (secmodname == NULL) return SECFailure; SECMOD_init(secmodname); @@ -241,13 +251,13 @@ loser: SECStatus NSS_Init(const char *configdir) { - return nss_Init(configdir, "", "", "secmod.db", PR_TRUE, PR_FALSE); + return nss_Init(configdir, "", "", SECMOD_DB, PR_TRUE, PR_FALSE); } SECStatus NSS_InitReadWrite(const char *configdir) { - return nss_Init(configdir, "", "", "secmod.db", PR_FALSE, PR_FALSE); + return nss_Init(configdir, "", "", SECMOD_DB, PR_FALSE, PR_FALSE); } SECStatus