Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Unified Diff: crypto/nss_util.cc

Issue 1111373003: crypto: Load libchaps.so with RTLD_DEEPBIND (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/Drop ours.// Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/nss_util.cc
diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc
index cd7bd448d934483a3ec2febdb9a1c4e2f2351c53..df9316054e76f97e136ec9885b7684d172225c84 100644
--- a/crypto/nss_util.cc
+++ b/crypto/nss_util.cc
@@ -18,6 +18,10 @@
#include <sys/param.h>
#endif
+#if defined(OS_CHROMEOS)
+#include <dlfcn.h>
+#endif
+
#include <map>
#include <vector>
@@ -267,6 +271,38 @@ class ChromeOSUserData {
SlotReadyCallbackList;
SlotReadyCallbackList tpm_ready_callback_list_;
};
+
+class ScopedChapsLoadFixup {
+ public:
+ ScopedChapsLoadFixup();
+ ~ScopedChapsLoadFixup();
+
+ private:
+#if defined(COMPONENT_BUILD)
+ void *chaps_handle_;
+#endif
+};
+
+#if defined(COMPONENT_BUILD)
+
+ScopedChapsLoadFixup::ScopedChapsLoadFixup() {
+ // HACK: libchaps links the system protobuf and there are symbol conflicts
+ // with the bundled copy. Load chaps with RTLD_DEEPBIND to workaround.
+ chaps_handle_ = dlopen(kChapsPath, RTLD_LOCAL | RTLD_NOW | RTLD_DEEPBIND);
+}
+
+ScopedChapsLoadFixup::~ScopedChapsLoadFixup() {
+ // LoadModule() will have taken a 2nd reference.
+ if (chaps_handle_)
+ dlclose(chaps_handle_);
+}
+
+#else
+
+ScopedChapsLoadFixup::ScopedChapsLoadFixup() {}
+ScopedChapsLoadFixup::~ScopedChapsLoadFixup() {}
+
+#endif // defined(COMPONENT_BUILD)
#endif // defined(OS_CHROMEOS)
class NSSInitSingleton {
@@ -360,6 +396,8 @@ class NSSInitSingleton {
// This tries to load the Chaps module so NSS can talk to the hardware
// TPM.
if (!tpm_args->chaps_module) {
+ ScopedChapsLoadFixup chaps_loader;
+
DVLOG(3) << "Loading chaps...";
tpm_args->chaps_module = LoadModule(
kChapsModuleName,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698