diff options
author | Moonchild <git-repo@palemoon.org> | 2020-03-20 09:43:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-20 09:43:07 +0100 |
commit | 0212d618116f86f7efd58dbb0a5ab9bfb3bb36d9 (patch) | |
tree | dcf21d873ead6863cb877d6732ba0f1fd0d6e533 /security | |
parent | 90a4813d175552d73d42230764f1d0aac7a66a27 (diff) | |
parent | 6f1d8fcce1f064447ccf778ea9925efae95bb5fc (diff) | |
download | UXP-0212d618116f86f7efd58dbb0a5ab9bfb3bb36d9.tar UXP-0212d618116f86f7efd58dbb0a5ab9bfb3bb36d9.tar.gz UXP-0212d618116f86f7efd58dbb0a5ab9bfb3bb36d9.tar.lz UXP-0212d618116f86f7efd58dbb0a5ab9bfb3bb36d9.tar.xz UXP-0212d618116f86f7efd58dbb0a5ab9bfb3bb36d9.zip |
Merge pull request #1487 from MoonchildProductions/1467
Make UXP applications capable of using SQLite for NSS instead of DBM
Diffstat (limited to 'security')
-rw-r--r-- | security/certverifier/NSSCertDBTrustDomain.cpp | 5 | ||||
-rw-r--r-- | security/manager/ssl/nsNSSComponent.cpp | 24 |
2 files changed, 27 insertions, 2 deletions
diff --git a/security/certverifier/NSSCertDBTrustDomain.cpp b/security/certverifier/NSSCertDBTrustDomain.cpp index 5e89c2484..cf48f6392 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 MOZ_SECURITY_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..897b5743c 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 MOZ_SECURITY_SQLSTORE +#include "mozStorageCID.h" +#endif #include "mozilla/ArrayUtils.h" #include "mozilla/Casting.h" #include "mozilla/Preferences.h" @@ -1703,16 +1706,25 @@ GetNSSProfilePath(nsAutoCString& aProfilePath) } #if defined(XP_WIN) - // Native path will drop Unicode characters that cannot be mapped to system's - // codepage, using short (canonical) path as workaround. nsCOMPtr<nsILocalFileWin> profileFileWin(do_QueryInterface(profileFile)); if (!profileFileWin) { MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("Could not get nsILocalFileWin for profile directory.\n")); return NS_ERROR_FAILURE; } +#ifdef MOZ_SECURITY_SQLSTORE + // SQLite always takes UTF-8 file paths regardless of the current system + // code page. + nsAutoString u16ProfilePath; + rv = profileFileWin->GetCanonicalPath(u16ProfilePath); + CopyUTF16toUTF8(u16ProfilePath, aProfilePath); +#else + // Native path will drop Unicode characters that cannot be mapped to system's + // codepage, using short (canonical) path as workaround. rv = profileFileWin->GetNativeCanonicalPath(aProfilePath); +#endif #else + // On non-Windows, just get the native profile path. rv = profileFile->GetNativePath(aProfilePath); #endif @@ -1970,6 +1982,14 @@ nsNSSComponent::Init() return NS_ERROR_NOT_SAME_THREAD; } +#ifdef MOZ_SECURITY_SQLSTORE + // To avoid an sqlite3_config race in NSS init, we require the storage service to get initialized first. + nsCOMPtr<nsISupports> 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")); |