From 899e14e94569ef668fdf10152d6c7296a6be4daa Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 16 Mar 2020 13:38:19 +0100 Subject: Issue #1467 - Part 1: Set up conditional NSS-SQL builds. - Adds buildconfig option --enable-nss-sqlstore - Prefixes NSS dbinit with either sql: or dbm: depending on config - Pre-initializes mozStorage when NSS-SQL storage is used to prevent an sqlite3_config race in NSS Init --- old-configure.in | 19 +++++++++++++++++++ security/certverifier/NSSCertDBTrustDomain.cpp | 5 +++++ security/manager/ssl/nsNSSComponent.cpp | 11 +++++++++++ 3 files changed, 35 insertions(+) diff --git a/old-configure.in b/old-configure.in index d438d9ea3..6c0b80d7b 100644 --- a/old-configure.in +++ b/old-configure.in @@ -2160,6 +2160,7 @@ MOZ_SERVICES_HEALTHREPORT=1 MOZ_SERVICES_SYNC=1 MOZ_USERINFO=1 NSS_DISABLE_DBM= +NSS_SQLSTORE= MOZ_MAILNEWS= MOZ_MAILNEWS_OAUTH2= MOZ_LDAP_XPCOM= @@ -2716,6 +2717,24 @@ fi AC_SUBST(NSS_DISABLE_DBM) +dnl ========================================================= +dnl = NSS SQL storage format +dnl ========================================================= +MOZ_ARG_ENABLE_BOOL(nss-sqlstore, +[ --enable-nss-sqlstore Enable the us of SQL storage for NSS], + NSS_SQLSTORE=1, + NSS_SQLSTORE=) + +if test -n "$NSS_DISABLE_DBM" -a -z "$NSS_SQLSTORE"; then + AC_MSG_ERROR([DBM storage support is required if not using NSS SQL storage]) +fi + +if test -n "$NSS_SQLSTORE"; then + AC_DEFINE(NSS_SQLSTORE) +fi + +AC_SUBST(NSS_SQLSTORE) + dnl ========================================================= dnl = Don't fold mailnews related comps into libXUL dnl ========================================================= diff --git a/security/certverifier/NSSCertDBTrustDomain.cpp b/security/certverifier/NSSCertDBTrustDomain.cpp index 5e89c2484..2793fad48 100644 --- a/security/certverifier/NSSCertDBTrustDomain.cpp +++ b/security/certverifier/NSSCertDBTrustDomain.cpp @@ -1102,7 +1102,12 @@ InitializeNSS(const nsACString& dir, bool readOnly, bool loadPKCS11Modules) flags |= NSS_INIT_NOMODDB; } nsAutoCString dbTypeAndDirectory; +#ifdef NSS_SQLSTORE + // Not strictly necessary with current NSS versions, but can't hurt to be explicit. + dbTypeAndDirectory.Append("sql:"); +#else dbTypeAndDirectory.Append("dbm:"); +#endif dbTypeAndDirectory.Append(dir); return ::NSS_Initialize(dbTypeAndDirectory.get(), "", "", SECMOD_DB, flags); } diff --git a/security/manager/ssl/nsNSSComponent.cpp b/security/manager/ssl/nsNSSComponent.cpp index dfff59da9..d505b8aba 100644 --- a/security/manager/ssl/nsNSSComponent.cpp +++ b/security/manager/ssl/nsNSSComponent.cpp @@ -12,6 +12,9 @@ #include "SharedSSLState.h" #include "cert.h" #include "certdb.h" +#ifdef NSS_SQLSTORE +#include "mozStorageCID.h" +#endif #include "mozilla/ArrayUtils.h" #include "mozilla/Casting.h" #include "mozilla/Preferences.h" @@ -1970,6 +1973,14 @@ nsNSSComponent::Init() return NS_ERROR_NOT_SAME_THREAD; } +#ifdef NSS_SQLSTORE + // To avoid an sqlite3_config race in NSS init, we require the storage service to get initialized first. + nsCOMPtr storageService = do_GetService(MOZ_STORAGE_SERVICE_CONTRACTID); + if (!storageService) { + return NS_ERROR_NOT_AVAILABLE; + } +#endif + nsresult rv = NS_OK; MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("Beginning NSS initialization\n")); -- cgit v1.2.3