Index: base/nss_util.cc |
diff --git a/base/nss_util.cc b/base/nss_util.cc |
index e4d1762baa75c572b07458bb43f3eed465edc922..1d40074ccb0c7223cfcbc1c2f128b90cd7fecaa0 100644 |
--- a/base/nss_util.cc |
+++ b/base/nss_util.cc |
@@ -5,6 +5,8 @@ |
#include "base/nss_util.h" |
#include "base/nss_util_internal.h" |
+#include <vector> |
wtc
2011/03/17 20:03:55
Nit: list C++ system headers after C system header
Alpha Left Google
2011/03/17 22:31:34
Done.
|
+ |
#include <nss.h> |
#include <plarena.h> |
#include <prerror.h> |
@@ -19,9 +21,11 @@ |
#endif |
#include "base/environment.h" |
+#include "base/file_path.h" |
#include "base/file_util.h" |
#include "base/lazy_instance.h" |
#include "base/logging.h" |
+#include "base/native_library.h" |
#include "base/scoped_ptr.h" |
#include "base/stringprintf.h" |
#include "base/threading/thread_restrictions.h" |
@@ -402,6 +406,43 @@ void DisableNSSForkCheck() { |
env->SetVar("NSS_STRICT_NOFORK", "DISABLED"); |
} |
+void LoadNSSLibraries() { |
+ // NSS libraries are linked dynamically on Linux so do this only on Linux. |
wtc
2011/03/17 20:03:55
Nit: add "Some". Not all NSS libraries are loaded
Alpha Left Google
2011/03/17 22:31:34
Done.
|
+#if defined(OS_LINUX) |
wtc
2011/03/17 20:03:55
It may be better to use defined(USE_NSS) or define
Alpha Left Google
2011/03/17 22:31:34
Done.
Alpha Left Google
2011/03/17 22:31:34
Done.
|
+ // Try to search for multiple directories to load the libraries. |
+ std::vector<FilePath> paths; |
+ paths.push_back(FilePath()); |
wtc
2011/03/17 20:03:55
Will this result in "/libsoftokn3.so" or "libsofto
Alpha Left Google
2011/03/17 22:31:34
This will load libsoftokn3.so.
|
+ paths.push_back(FilePath("/usr/lib/nss")); |
wtc
2011/03/17 20:03:55
Please document this is for Debian and its derivat
Alpha Left Google
2011/03/17 22:31:34
Done.
|
+ |
+ // A list of library files to load. |
+ std::vector<std::string> libs; |
+ libs.push_back("libsoftokn3.so"); |
+ libs.push_back("libfreebl3.so"); |
+ |
+ // For each combination of library file and path, check for existence and |
+ // then load. |
+ size_t loaded = 0; |
+ for (size_t i = 0; i < libs.size(); ++i) { |
+ for (size_t j = 0; j < paths.size(); ++j) { |
+ FilePath path = paths[j].Append(libs[i]); |
+ if (file_util::PathExists(path)) { |
+ NativeLibrary lib = base::LoadNativeLibrary(path); |
+ if (lib) { |
+ ++loaded; |
+ break; |
+ } |
+ } |
+ } |
+ } |
+ |
+ if (loaded == libs.size()) { |
+ LOG(INFO) << "NSS libraries loaded."; |
+ } else { |
+ LOG(WARNING) << "Failed to load NSS libraries."; |
wtc
2011/03/17 20:03:55
This should be LOG(ERROR).
The LOG(INFO) should b
Alpha Left Google
2011/03/17 22:31:34
Done.
|
+ } |
+#endif |
+} |
+ |
bool CheckNSSVersion(const char* version) { |
return !!NSS_VersionCheck(version); |
} |