mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 11:15:34 +00:00
On WinCE, DBM's dbopen uses NSPR file open flags rather than libc's
file open flags (which are not defined on WinCE).
This commit is contained in:
parent
977f0c234a
commit
130c1e83db
@ -95,3 +95,7 @@ MKSHLIB += -R '$$ORIGIN'
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_TARGET),WINCE)
|
||||
DEFINES += -DDBM_USING_NSPR
|
||||
endif
|
||||
|
@ -32,7 +32,7 @@
|
||||
*
|
||||
* Private Key Database code
|
||||
*
|
||||
* $Id: keydb.c,v 1.13 2002/02/21 22:41:37 ian.mcgreer%sun.com Exp $
|
||||
* $Id: keydb.c,v 1.14 2002/04/05 03:33:42 nelsonb%netscape.com Exp $
|
||||
*/
|
||||
|
||||
#include "lowkeyi.h"
|
||||
@ -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;
|
||||
|
@ -34,7 +34,7 @@
|
||||
/*
|
||||
* Permanent Certificate database handling code
|
||||
*
|
||||
* $Id: pcertdb.c,v 1.13 2002/01/31 00:16:29 relyea%netscape.com Exp $
|
||||
* $Id: pcertdb.c,v 1.14 2002/04/05 03:33:42 nelsonb%netscape.com Exp $
|
||||
*/
|
||||
#include "prtime.h"
|
||||
|
||||
@ -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! */
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user