Chromium Code Reviews| Index: crypto/nss_util.cc |
| diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc |
| index cd7bd448d934483a3ec2febdb9a1c4e2f2351c53..853c0cecd8e0c142dd6b8027eef01a824c6bde76 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. Drop ours. |
|
Ryan Sleevi
2015/05/13 22:35:51
s/Drop ours.//
(In general, I grumble about prono
|
| + 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, |