if (appName) { updatedb = dbsopen(certdbname, NO_RDONLY, 0600, DB_HASH, 0); if (updatedb) { rv = UpdateV8DB(handle, updatedb); db_FinishTransaction(handle->permCertDB,PR_FALSE); db_InitComplete(handle->permCertDB); return(rv); } }
openNewCertDB(const char *appName, const char *prefix, const char *certdbname,     NSSLOWCERTCertDBHandle *handle, NSSLOWCERTDBNameFunc namecb, void *cbarg){    SECStatus rv;    certDBEntryVersion *versionEntry = NULL;    DB *updatedb = NULL;    int status = RDB_FAIL;    if (appName) {	handle->permCertDB=rdbopen( appName, prefix, "cert", NO_CREATE, &status);    } else {	handle->permCertDB=dbsopen(certdbname, NO_CREATE, 0600, DB_HASH, 0);    }    /* if create fails then we lose */    if ( handle->permCertDB == 0 ) {	return status == RDB_RETRY ? SECWouldBlock : SECFailure;    }    rv = db_BeginTransaction(handle->permCertDB);    if (rv != SECSuccess) {	db_InitComplete(handle->permCertDB);	return SECFailure;    }    /* Verify version number; */    if (appName) {	updatedb = dbsopen(certdbname, NO_RDONLY, 0600, DB_HASH, 0);	if (updatedb) {	    rv = UpdateV8DB(handle, updatedb);	    db_FinishTransaction(handle->permCertDB,PR_FALSE);	    db_InitComplete(handle->permCertDB);	    return(rv);	}    }    versionEntry = NewDBVersionEntry(0);    if ( versionEntry == NULL ) {	rv = SECFailure;	goto loser;    }	    rv = WriteDBVersionEntry(handle, versionEntry);    DestroyDBEntry((certDBEntry *)versionEntry);    if ( rv != SECSuccess ) {	goto loser;    }    /* rv must already be Success here because of previous if statement */    /* try to upgrade old db here */    if ((updatedb = nsslowcert_openolddb(namecb,cbarg,7)) != NULL) {	rv = UpdateV7DB(handle, updatedb);    } else if ((updatedb = nsslowcert_openolddb(namecb,cbarg,6)) != NULL) {	rv = UpdateV6DB(handle, updatedb);    } else if ((updatedb = nsslowcert_openolddb(namecb,cbarg,5)) != NULL) {	rv = UpdateV5DB(handle, updatedb);    } else if ((updatedb = nsslowcert_openolddb(namecb,cbarg,4)) != NULL) {	/* NES has v5 format db's with v4 db names! */	if (isV4DB(updatedb)) {	    rv = UpdateV4DB(handle,updatedb);	} else {	    rv = UpdateV5DB(handle,updatedb);	}    }loser:    db_FinishTransaction(handle->permCertDB,rv != SECSuccess);    db_InitComplete(handle->permCertDB);    return rv;}