Bug 712579 - Load nssckbi from the location of nss3. r=kaie
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 27 Dec 2011 18:11:17 +0100
changeset 84254 345863ffe8c8c9f04e1b1ace6ea628073f29cd23
parent 84253 4202e19f36e29ed8f9d95fe5747cf352b1209d6d
child 84255 2a6cac678c94d9fe78c11b837b270e3304fc2df7
push id21832
push userbmo@edmorley.co.uk
push dateWed, 11 Jan 2012 17:04:15 +0000
treeherdermozilla-central@40c9f9ff9fd5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskaie
bugs712579
milestone12.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 712579 - Load nssckbi from the location of nss3. r=kaie
security/manager/ssl/src/Makefile.in
security/manager/ssl/src/nsNSSComponent.cpp
--- a/security/manager/ssl/src/Makefile.in
+++ b/security/manager/ssl/src/Makefile.in
@@ -110,16 +110,20 @@ ifdef MOZ_XUL
 CPPSRCS += nsCertTree.cpp
 endif
 
 CSRCS += md4.c
 
 
 EXTRA_DEPS = $(NSS_DEP_LIBS)
 
-DEFINES += -DNSS_ENABLE_ECC
+DEFINES += \
+  -DNSS_ENABLE_ECC \
+  -DDLL_PREFIX=\"$(DLL_PREFIX)\" \
+  -DDLL_SUFFIX=\"$(DLL_SUFFIX)\" \
+  $(NULL)
 
 # Use local includes because they are inserted before INCLUDES
 # so that Mozilla's nss.h is used, not glibc's
 LOCAL_INCLUDES += $(NSS_CFLAGS)
 
 include $(topsrcdir)/config/rules.mk
 
--- a/security/manager/ssl/src/nsNSSComponent.cpp
+++ b/security/manager/ssl/src/nsNSSComponent.cpp
@@ -823,17 +823,20 @@ nsNSSComponent::InstallLoadableRoots()
   nsAutoString modName;
   rv = GetPIPNSSBundleString("RootCertModuleName", modName);
   if (NS_FAILED(rv)) return;
 
   nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
   if (!directoryService)
     return;
 
+  static const char nss_lib[] = "nss3";
   const char *possible_ckbi_locations[] = {
+    nss_lib, // This special value means: search for ckbi in the directory
+             // where nss3 is.
     NS_XPCOM_CURRENT_PROCESS_DIR,
     NS_GRE_DIR,
     0 // This special value means: 
       //   search for ckbi in the directories on the shared
       //   library/DLL search path
   };
 
   for (size_t il = 0; il < sizeof(possible_ckbi_locations)/sizeof(const char*); ++il) {
@@ -841,19 +844,40 @@ nsNSSComponent::InstallLoadableRoots()
     char *fullLibraryPath = nsnull;
 
     if (!possible_ckbi_locations[il])
     {
       fullLibraryPath = PR_GetLibraryName(nsnull, "nssckbi");
     }
     else
     {
-      directoryService->Get( possible_ckbi_locations[il],
-                             NS_GET_IID(nsILocalFile), 
-                             getter_AddRefs(mozFile));
+      if (possible_ckbi_locations[il] == nss_lib) {
+        // Get the location of the nss3 library.
+        char *nss_path = PR_GetLibraryFilePathname(DLL_PREFIX "nss3" DLL_SUFFIX,
+                                                   (PRFuncPtr) NSS_Initialize);
+        if (!nss_path) {
+          continue;
+        }
+        // Get the directory containing the nss3 library.
+        nsCOMPtr<nsILocalFile> nssLib(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
+        if (NS_SUCCEEDED(rv)) {
+          rv = nssLib->InitWithNativePath(nsDependentCString(nss_path));
+        }
+        PR_Free(nss_path);
+        if (NS_SUCCEEDED(rv)) {
+          nsCOMPtr<nsIFile> file;
+          if (NS_SUCCEEDED(nssLib->GetParent(getter_AddRefs(file)))) {
+            mozFile = do_QueryInterface(file);
+          }
+        }
+      } else {
+        directoryService->Get( possible_ckbi_locations[il],
+                               NS_GET_IID(nsILocalFile), 
+                               getter_AddRefs(mozFile));
+      }
   
       if (!mozFile) {
         continue;
       }
 
       nsCAutoString processDir;
       mozFile->GetNativePath(processDir);
       fullLibraryPath = PR_GetLibraryName(processDir.get(), "nssckbi");