summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornelsonb%netscape.com <devnull@localhost>2002-04-05 02:35:54 +0000
committernelsonb%netscape.com <devnull@localhost>2002-04-05 02:35:54 +0000
commit8d3a1864be1f81e7300acf2dc2a14b3bf0de1cdb (patch)
tree968cb1c02d6a9e783820d67b24b4f45c235df11e
parent37f1bd20cb3c106f4973771670504c8b6e36c521 (diff)
downloadnss-hg-8d3a1864be1f81e7300acf2dc2a14b3bf0de1cdb.tar.gz
Changes to build on WinCE. Use NSPR version of DBM. Warning reduction.
-rw-r--r--security/nss/lib/softoken/config.mk4
-rw-r--r--security/nss/lib/softoken/keydb.c33
-rw-r--r--security/nss/lib/softoken/pcertdb.c32
-rw-r--r--security/nss/lib/softoken/pk11db.c54
4 files changed, 78 insertions, 45 deletions
diff --git a/security/nss/lib/softoken/config.mk b/security/nss/lib/softoken/config.mk
index b59f0cf32..0d72934be 100644
--- a/security/nss/lib/softoken/config.mk
+++ b/security/nss/lib/softoken/config.mk
@@ -95,3 +95,7 @@ MKSHLIB += -R '$$ORIGIN'
endif
endif
endif
+
+ifeq ($(OS_TARGET),WINCE)
+DEFINES += -DDBM_USING_NSPR
+endif
diff --git a/security/nss/lib/softoken/keydb.c b/security/nss/lib/softoken/keydb.c
index 2f9c1bdda..a8db1673b 100644
--- a/security/nss/lib/softoken/keydb.c
+++ b/security/nss/lib/softoken/keydb.c
@@ -958,8 +958,15 @@ done:
return(SECSuccess);
}
-
-
+#ifdef DBM_USING_NSPR
+#define NO_RDONLY PR_RDONLY
+#define NO_RDWR PR_RDWR
+#define NO_CREATE (PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE)
+#else
+#define NO_RDONLY O_RDONLY
+#define NO_RDWR O_RDWR
+#define NO_CREATE (O_RDWR | O_CREAT | O_TRUNC)
+#endif
NSSLOWKEYDBHandle *
nsslowkey_OpenKeyDB(PRBool readOnly, NSSLOWKEYDBNameFunc namecb, void *cbarg)
@@ -976,12 +983,8 @@ nsslowkey_OpenKeyDB(PRBool readOnly, NSSLOWKEYDBNameFunc namecb, void *cbarg)
PORT_SetError (SEC_ERROR_NO_MEMORY);
return NULL;
}
-
- if ( readOnly ) {
- openflags = O_RDONLY;
- } else {
- openflags = O_RDWR;
- }
+
+ openflags = readOnly ? NO_RDONLY : NO_RDWR;
dbname = (*namecb)(cbarg, NSSLOWKEY_DB_FILE_VERSION);
if ( dbname == NULL ) {
@@ -1020,7 +1023,7 @@ newdb:
if (dbname3 == NULL) {
goto loser;
}
- handle->db = dbopen( dbname3, O_RDONLY, 0600, DB_HASH, 0 );
+ handle->db = dbopen( dbname3, NO_RDONLY, 0600, DB_HASH, 0 );
PORT_Free(handle->dbname);
handle->dbname = dbname3;
dbname3 = NULL;
@@ -1041,9 +1044,8 @@ newdb:
goto loser;
}
#endif
-
- handle->db = dbopen( dbname,
- O_RDWR | O_CREAT | O_TRUNC, 0600, DB_HASH, 0 );
+
+ handle->db = dbopen( dbname, NO_CREATE, 0600, DB_HASH, 0 );
PORT_Free( dbname );
dbname = NULL;
@@ -1059,7 +1061,7 @@ newdb:
}
#ifdef NSS_USE_KEY4_DB
- handle->updatedb = dbopen( dbname3, O_RDONLY, 0600, DB_HASH, 0 );
+ handle->updatedb = dbopen( dbname3, NO_RDONLY, 0600, DB_HASH, 0 );
PORT_Free(dbname3);
dbname3 = NULL;
if (handle->updatedb) {
@@ -1078,7 +1080,7 @@ newdb:
*/
dbname = (*namecb)(cbarg, 2);
if ( dbname != NULL ) {
- handle->updatedb = dbopen( dbname, O_RDONLY, 0600, DB_HASH, 0 );
+ handle->updatedb = dbopen( dbname, NO_RDONLY, 0600, DB_HASH, 0 );
PORT_Free( dbname );
dbname = NULL;
@@ -2542,8 +2544,7 @@ nsslowkey_ResetKeyDB(NSSLOWKEYDBHandle *handle)
}
(* handle->db->close)(handle->db);
- handle->db = dbopen( handle->dbname,
- O_RDWR | O_CREAT | O_TRUNC, 0600, DB_HASH, 0 );
+ handle->db = dbopen( handle->dbname, NO_CREATE, 0600, DB_HASH, 0 );
if (handle->db == NULL) {
/* set an error code */
return SECFailure;
diff --git a/security/nss/lib/softoken/pcertdb.c b/security/nss/lib/softoken/pcertdb.c
index b392d36a3..f87bbbe46 100644
--- a/security/nss/lib/softoken/pcertdb.c
+++ b/security/nss/lib/softoken/pcertdb.c
@@ -3535,6 +3535,16 @@ nsslowcert_CertNicknameConflict(char *nickname, SECItem *derSubject,
return(rv);
}
+#ifdef DBM_USING_NSPR
+#define NO_RDONLY PR_RDONLY
+#define NO_RDWR PR_RDWR
+#define NO_CREATE (PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE)
+#else
+#define NO_RDONLY O_RDONLY
+#define NO_RDWR O_RDWR
+#define NO_CREATE (O_RDWR | O_CREAT | O_TRUNC)
+#endif
+
/*
* Open the certificate database and index databases. Create them if
* they are not there or bad.
@@ -3556,13 +3566,9 @@ nsslowcert_OpenPermCertDB(NSSLOWCERTCertDBHandle *handle, PRBool readOnly,
if ( certdbname == NULL ) {
return(SECFailure);
}
-
- if ( readOnly ) {
- openflags = O_RDONLY;
- } else {
- openflags = O_RDWR;
- }
-
+
+ openflags = readOnly ? NO_RDONLY : NO_RDWR;
+
/*
* first open the permanent file based database.
*/
@@ -3596,9 +3602,7 @@ nsslowcert_OpenPermCertDB(NSSLOWCERTCertDBHandle *handle, PRBool readOnly,
goto loser;
}
- handle->permCertDB = dbopen(certdbname,
- O_RDWR | O_CREAT | O_TRUNC,
- 0600, DB_HASH, 0);
+ handle->permCertDB = dbopen(certdbname, NO_CREATE, 0600, DB_HASH, 0);
/* if create fails then we lose */
if ( handle->permCertDB == 0 ) {
@@ -3621,7 +3625,7 @@ nsslowcert_OpenPermCertDB(NSSLOWCERTCertDBHandle *handle, PRBool readOnly,
/* try to upgrade old db here */
tmpname = (* namecb)(cbarg, 6); /* get v6 db name */
if ( tmpname ) {
- updatedb = dbopen( tmpname, O_RDONLY, 0600, DB_HASH, 0 );
+ updatedb = dbopen( tmpname, NO_RDONLY, 0600, DB_HASH, 0 );
PORT_Free(tmpname);
if ( updatedb ) {
rv = UpdateV6DB(handle, updatedb);
@@ -3632,7 +3636,7 @@ nsslowcert_OpenPermCertDB(NSSLOWCERTCertDBHandle *handle, PRBool readOnly,
} else { /* no v6 db, so try v5 db */
tmpname = (* namecb)(cbarg, 5); /* get v5 db name */
if ( tmpname ) {
- updatedb = dbopen( tmpname, O_RDONLY, 0600, DB_HASH, 0 );
+ updatedb = dbopen( tmpname, NO_RDONLY, 0600, DB_HASH, 0 );
PORT_Free(tmpname);
if ( updatedb ) {
rv = UpdateV5DB(handle, updatedb);
@@ -3644,8 +3648,8 @@ nsslowcert_OpenPermCertDB(NSSLOWCERTCertDBHandle *handle, PRBool readOnly,
/* try to upgrade v4 db */
tmpname = (* namecb)(cbarg, 4); /* get v4 db name */
if ( tmpname ) {
- updatedb = dbopen( tmpname, O_RDONLY, 0600,
- DB_HASH, 0 );
+ updatedb = dbopen( tmpname, NO_RDONLY, 0600,
+ DB_HASH, 0 );
PORT_Free(tmpname);
if ( updatedb ) {
/* NES has v5 db's with v4 db names! */
diff --git a/security/nss/lib/softoken/pk11db.c b/security/nss/lib/softoken/pk11db.c
index fcc906d06..794b8384d 100644
--- a/security/nss/lib/softoken/pk11db.c
+++ b/security/nss/lib/softoken/pk11db.c
@@ -296,7 +296,9 @@ static SECStatus secmod_MakeKey(DBT *key, char * module) {
}
/* free out constructed database key */
-static void secmod_FreeKey(DBT *key) {
+static void
+secmod_FreeKey(DBT *key)
+{
if (key->data) {
PORT_Free(key->data);
}
@@ -359,7 +361,9 @@ struct secmodSlotDataStr {
/*
* build a data base entry from a module
*/
-static SECStatus secmod_EncodeData(DBT *data, char * module) {
+static SECStatus
+secmod_EncodeData(DBT *data, char * module)
+{
secmodData *encoded = NULL;
secmodSlotData *slot;
unsigned char *dataPtr;
@@ -437,7 +441,7 @@ static SECStatus secmod_EncodeData(DBT *data, char * module) {
SECMOD_PUTLONG(encoded->ssl,ssl[0]);
SECMOD_PUTLONG(&encoded->ssl[4],ssl[1]);
- offset = (unsigned long) &(((secmodData *)0)->names[0]);
+ offset = (unsigned short) &(((secmodData *)0)->names[0]);
SECMOD_PUTSHORT(encoded->nameStart,offset);
offset = offset + len + len2 + len3 + 3*sizeof(unsigned short);
SECMOD_PUTSHORT(encoded->slotOffset,offset);
@@ -611,8 +615,10 @@ secmod_DecodeData(char *defParams, DBT *data, PRBool *retInternal)
trustOrder = 100;
}
- slotStrings[i] = pk11_mkSlotString(slotID,defaultFlags,
- timeout,slots[i].askpw,hasRootCerts,hasRootTrust);
+ slotStrings[i] = pk11_mkSlotString(slotID, defaultFlags, timeout,
+ (unsigned char)slots[i].askpw,
+ (unsigned char)hasRootCerts,
+ (unsigned char)hasRootTrust);
}
nss = pk11_mkNSS(slotStrings, slotCount, internal, isFIPS, isModuleDB,
@@ -625,25 +631,40 @@ secmod_DecodeData(char *defParams, DBT *data, PRBool *retInternal)
}
+#ifdef DBM_USING_NSPR
+#define NO_RDONLY PR_RDONLY
+#define NO_RDWR PR_RDWR
+#define NO_CREATE (PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE)
+#else
+#define NO_RDONLY O_RDONLY
+#define NO_RDWR O_RDWR
+#define NO_CREATE (O_RDWR | O_CREAT | O_TRUNC)
+#endif
-static DB *secmod_OpenDB(char *dbName, PRBool readOnly) {
+
+static DB *
+secmod_OpenDB(char *dbName, PRBool readOnly)
+{
DB *pkcs11db = NULL;
/* I'm sure we should do more checks here sometime... */
- pkcs11db = dbopen(dbName, readOnly ? O_RDONLY : O_RDWR, 0600, DB_HASH, 0);
+ pkcs11db = dbopen(dbName, readOnly ? NO_RDONLY : NO_RDWR, 0600, DB_HASH, 0);
/* didn't exist? create it */
if (pkcs11db == NULL) {
- if (readOnly) return NULL;
+ if (readOnly)
+ return NULL;
- pkcs11db = dbopen( dbName,
- O_RDWR | O_CREAT | O_TRUNC, 0600, DB_HASH, 0 );
- if (pkcs11db) (* pkcs11db->sync)(pkcs11db, 0);
+ pkcs11db = dbopen( dbName, NO_CREATE, 0600, DB_HASH, 0 );
+ if (pkcs11db)
+ (* pkcs11db->sync)(pkcs11db, 0);
}
return pkcs11db;
}
-static void secmod_CloseDB(DB *pkcs11db) {
+static void
+secmod_CloseDB(DB *pkcs11db)
+{
(*pkcs11db->close)(pkcs11db);
}
@@ -681,7 +702,8 @@ secmod_addEscape(const char *string, char quote)
* Read all the existing modules in
*/
char **
-secmod_ReadPermDB(char *dbname, char *params, PRBool rw) {
+secmod_ReadPermDB(char *dbname, char *params, PRBool rw)
+{
DBT key,data;
int ret;
DB *pkcs11db = NULL;
@@ -743,7 +765,8 @@ done:
* Delete a module from the Data Base
*/
SECStatus
-secmod_DeletePermDB(char *dbname, char *args, PRBool rw) {
+secmod_DeletePermDB(char *dbname, char *args, PRBool rw)
+{
DBT key;
SECStatus rv = SECFailure;
DB *pkcs11db = NULL;
@@ -777,7 +800,8 @@ done:
* Add a module to the Data base
*/
SECStatus
-secmod_AddPermDB(char *dbname, char *module, PRBool rw) {
+secmod_AddPermDB(char *dbname, char *module, PRBool rw)
+{
DBT key,data;
SECStatus rv = SECFailure;
DB *pkcs11db = NULL;