Index: components/nacl/renderer/plugin/module_ppapi.cc |
diff --git a/components/nacl/renderer/plugin/module_ppapi.cc b/components/nacl/renderer/plugin/module_ppapi.cc |
index 6b090f091c489c31c429b7d50faf7b07544bff0b..cb0ae3cd25cabec55cb28d324a1c3ce1847a7284 100644 |
--- a/components/nacl/renderer/plugin/module_ppapi.cc |
+++ b/components/nacl/renderer/plugin/module_ppapi.cc |
@@ -7,14 +7,21 @@ |
#include "components/nacl/renderer/plugin/module_ppapi.h" |
#include "components/nacl/renderer/plugin/plugin.h" |
#include "components/nacl/renderer/plugin/utility.h" |
+#include "native_client/src/shared/platform/nacl_secure_random.h" |
+#include "native_client/src/shared/platform/nacl_time.h" |
+#include "native_client/src/trusted/desc/nrd_all_modules.h" |
namespace plugin { |
ModulePpapi::ModulePpapi() : pp::Module(), |
+ init_was_successful_(false), |
private_interface_(NULL) { |
} |
ModulePpapi::~ModulePpapi() { |
+ if (init_was_successful_) { |
+ NaClNrdAllModulesFini(); |
+ } |
} |
bool ModulePpapi::Init() { |
@@ -27,6 +34,19 @@ |
} |
SetNaClInterface(private_interface_); |
+#if NACL_LINUX || NACL_OSX |
+ // Note that currently we do not need random numbers inside the |
+ // NaCl trusted plugin on Unix, but NaClSecureRngModuleInit() is |
+ // strict and will raise a fatal error unless we provide it with a |
+ // /dev/urandom FD beforehand. |
+ NaClSecureRngModuleSetUrandomFd(dup(private_interface_->UrandomFD())); |
+#endif |
+ |
+ // In the plugin, we don't need high resolution time of day. |
+ NaClAllowLowResolutionTimeOfDay(); |
+ NaClNrdAllModulesInit(); |
+ |
+ init_was_successful_ = true; |
return true; |
} |