Request NSS to use DBM as the storage file format

This commit is contained in:
JustOff 2018-06-06 15:41:35 +03:00 • committed by Roy Tam
commit 7ff80ee648
4 changed files with 17 additions and 5 deletions

View file

@ -22,6 +22,7 @@
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
#include "nsNSSCertificate.h" #include "nsNSSCertificate.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
#include "nss.h" #include "nss.h"
#include "pk11pub.h" #include "pk11pub.h"
#include "pkix/Result.h" #include "pkix/Result.h"
@ -1087,8 +1088,10 @@ NSSCertDBTrustDomain::NoteAuxiliaryExtension(AuxiliaryExtension extension,
} }
SECStatus SECStatus
InitializeNSS(const char* dir, bool readOnly, bool loadPKCS11Modules) InitializeNSS(const nsACString& dir, bool readOnly, bool loadPKCS11Modules)
{ {
MOZ_ASSERT(NS_IsMainThread());
// The NSS_INIT_NOROOTINIT flag turns off the loading of the root certs // The NSS_INIT_NOROOTINIT flag turns off the loading of the root certs
// module by NSS_Initialize because we will load it in InstallLoadableRoots // module by NSS_Initialize because we will load it in InstallLoadableRoots
// later. It also allows us to work around a bug in the system NSS in // later. It also allows us to work around a bug in the system NSS in
@ -1101,7 +1104,10 @@ InitializeNSS(const char* dir, bool readOnly, bool loadPKCS11Modules)
if (!loadPKCS11Modules) { if (!loadPKCS11Modules) {
flags |= NSS_INIT_NOMODDB; flags |= NSS_INIT_NOMODDB;
} }
return ::NSS_Initialize(dir, "", "", SECMOD_DB, flags); nsAutoCString dbTypeAndDirectory;
dbTypeAndDirectory.Append("dbm:");
dbTypeAndDirectory.Append(dir);
return ::NSS_Initialize(dbTypeAndDirectory.get(), "", "", SECMOD_DB, flags);
} }
void void

View file

@ -36,7 +36,8 @@ enum class NetscapeStepUpPolicy : uint32_t {
NeverMatch = 3, NeverMatch = 3,
}; };
SECStatus InitializeNSS(const char* dir, bool readOnly, bool loadPKCS11Modules); SECStatus InitializeNSS(const nsACString& dir, bool readOnly,
bool loadPKCS11Modules);
void DisableMD5(); void DisableMD5();

View file

@ -68,6 +68,11 @@ if CONFIG['_MSC_VER']:
# class copy constructor is inaccessible or deleted # class copy constructor is inaccessible or deleted
'-wd4626', # assignment operator could not be generated because a base '-wd4626', # assignment operator could not be generated because a base
# class assignment operator is inaccessible or deleted # class assignment operator is inaccessible or deleted
'-wd4628', # digraphs not supported with -Ze (nsThreadUtils.h includes
# what would be the digraph "<:" in the expression
# "mozilla::EnableIf<::detail::...". Since we don't want it
# interpreted as a digraph anyway, we can disable the
# warning.)
'-wd4640', # construction of local static object is not thread-safe '-wd4640', # construction of local static object is not thread-safe
'-wd4710', # 'function': function not inlined '-wd4710', # 'function': function not inlined
'-wd4711', # function 'function' selected for inline expansion '-wd4711', # function 'function' selected for inline expansion

View file

@ -1828,11 +1828,11 @@ nsNSSComponent::InitializeNSS()
if (!nocertdb && !profileStr.IsEmpty()) { if (!nocertdb && !profileStr.IsEmpty()) {
// First try to initialize the NSS DB in read/write mode. // First try to initialize the NSS DB in read/write mode.
// Only load PKCS11 modules if we're not in safe mode. // Only load PKCS11 modules if we're not in safe mode.
init_rv = ::mozilla::psm::InitializeNSS(profileStr.get(), false, !inSafeMode); init_rv = ::mozilla::psm::InitializeNSS(profileStr, false, !inSafeMode);
// If that fails, attempt read-only mode. // If that fails, attempt read-only mode.
if (init_rv != SECSuccess) { if (init_rv != SECSuccess) {
MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("could not init NSS r/w in %s\n", profileStr.get())); MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("could not init NSS r/w in %s\n", profileStr.get()));
init_rv = ::mozilla::psm::InitializeNSS(profileStr.get(), true, !inSafeMode); init_rv = ::mozilla::psm::InitializeNSS(profileStr, true, !inSafeMode);
} }
if (init_rv != SECSuccess) { if (init_rv != SECSuccess) {
MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("could not init in r/o either\n")); MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("could not init in r/o either\n"));