| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 77 } |
| 78 // Check that there was exactly one descriptor passed. | 78 // Check that there was exactly one descriptor passed. |
| 79 if (1 != header.ndescv_length) { | 79 if (1 != header.ndescv_length) { |
| 80 return NULL; | 80 return NULL; |
| 81 } | 81 } |
| 82 | 82 |
| 83 return descs[0]; | 83 return descs[0]; |
| 84 } | 84 } |
| 85 | 85 |
| 86 bool SelLdrLauncher::LoadModule(NaClSrpcChannel* command, DescWrapper* nexe) { | 86 bool SelLdrLauncher::LoadModule(NaClSrpcChannel* command, DescWrapper* nexe) { |
| 87 | |
| 88 NaClLog(4, "Entered SelLdrLauncher::LoadModule\n"); | 87 NaClLog(4, "Entered SelLdrLauncher::LoadModule\n"); |
| 89 NaClSrpcResultCodes rpc_result = NaClSrpcInvokeBySignature(command, | 88 NaClSrpcResultCodes rpc_result = NaClSrpcInvokeBySignature(command, |
| 90 "load_module:hs:", | 89 "load_module:hs:", |
| 91 nexe->desc(), | 90 nexe->desc(), |
| 92 "place holder"); | 91 "place holder"); |
| 93 NaClLog(4, "SelLdrLauncher::LoadModule rpc result %d\n", (int) rpc_result); | 92 NaClLog(4, "SelLdrLauncher::LoadModule rpc result %d\n", (int) rpc_result); |
| 94 return NACL_SRPC_RESULT_OK == rpc_result; | 93 return NACL_SRPC_RESULT_OK == rpc_result; |
| 95 } | 94 } |
| 96 | 95 |
| 97 bool SelLdrLauncher::StartModule(NaClSrpcChannel* command, | 96 bool SelLdrLauncher::StartModule(NaClSrpcChannel* command, |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 return false; | 214 return false; |
| 216 } | 215 } |
| 217 if (!SetupApplicationChannel(out_app_chan)) { | 216 if (!SetupApplicationChannel(out_app_chan)) { |
| 218 return false; | 217 return false; |
| 219 } | 218 } |
| 220 | 219 |
| 221 return true; | 220 return true; |
| 222 } | 221 } |
| 223 | 222 |
| 224 #ifdef NACL_STANDALONE | 223 #ifdef NACL_STANDALONE |
| 224 /* @IGNORE_LINES_FOR_CODE_HYGIENE[1] */ |
| 225 extern "C" char **environ; | 225 extern "C" char **environ; |
| 226 | 226 |
| 227 static char **GetEnviron() { | 227 static char **GetEnviron() { |
| 228 #if NACL_OSX | 228 #if NACL_OSX |
| 229 /* Mac dynamic libraries cannot access the environ variable directly. */ | 229 /* Mac dynamic libraries cannot access the environ variable directly. */ |
| 230 return *_NSGetEnviron(); | 230 return *_NSGetEnviron(); |
| 231 #else | 231 #else |
| 232 return environ; | 232 return environ; |
| 233 #endif | 233 #endif |
| 234 } | 234 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 254 command->insert(command->end(), sel_ldr_argv_.begin(), sel_ldr_argv_.end()); | 254 command->insert(command->end(), sel_ldr_argv_.begin(), sel_ldr_argv_.end()); |
| 255 | 255 |
| 256 // Our use of "environ" above fails to link in the "shared" (DLL) | 256 // Our use of "environ" above fails to link in the "shared" (DLL) |
| 257 // build of Chromium on Windows. However, we do not use | 257 // build of Chromium on Windows. However, we do not use |
| 258 // BuildCommandLine() when integrated into Chromium anyway -- we use | 258 // BuildCommandLine() when integrated into Chromium anyway -- we use |
| 259 // sel_main_chrome.c -- so it is safe to disable this code, which is | 259 // sel_main_chrome.c -- so it is safe to disable this code, which is |
| 260 // largely for debugging. | 260 // largely for debugging. |
| 261 // TODO(mseaborn): Tidy this up so that we do not need a conditional. | 261 // TODO(mseaborn): Tidy this up so that we do not need a conditional. |
| 262 #ifdef NACL_STANDALONE | 262 #ifdef NACL_STANDALONE |
| 263 struct NaClEnvCleanser env_cleanser; | 263 struct NaClEnvCleanser env_cleanser; |
| 264 NaClEnvCleanserCtor(&env_cleanser); | 264 NaClEnvCleanserCtor(&env_cleanser, 1); |
| 265 if (!NaClEnvCleanserInit(&env_cleanser, GetEnviron())) { | 265 if (!NaClEnvCleanserInit(&env_cleanser, GetEnviron(), NULL)) { |
| 266 NaClLog(LOG_FATAL, "Failed to initialise env cleanser\n"); | 266 NaClLog(LOG_FATAL, "Failed to initialise env cleanser\n"); |
| 267 } | 267 } |
| 268 for (const char* const* env = NaClEnvCleanserEnvironment(&env_cleanser); | 268 for (const char* const* env = NaClEnvCleanserEnvironment(&env_cleanser); |
| 269 *env != NULL; | 269 *env != NULL; |
| 270 ++env) { | 270 ++env) { |
| 271 command->push_back("-E"); | 271 command->push_back("-E"); |
| 272 command->push_back(*env); | 272 command->push_back(*env); |
| 273 } | 273 } |
| 274 NaClEnvCleanserDtor(&env_cleanser); | 274 NaClEnvCleanserDtor(&env_cleanser); |
| 275 #endif | 275 #endif |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 CHECK(factory_ != NULL); | 311 CHECK(factory_ != NULL); |
| 312 return factory_->MakeGeneric(raw_desc); | 312 return factory_->MakeGeneric(raw_desc); |
| 313 } | 313 } |
| 314 | 314 |
| 315 DescWrapper* SelLdrLauncher::WrapCleanup(NaClDesc* raw_desc) { | 315 DescWrapper* SelLdrLauncher::WrapCleanup(NaClDesc* raw_desc) { |
| 316 CHECK(factory_ != NULL); | 316 CHECK(factory_ != NULL); |
| 317 return factory_->MakeGenericCleanup(raw_desc); | 317 return factory_->MakeGenericCleanup(raw_desc); |
| 318 } | 318 } |
| 319 | 319 |
| 320 } // namespace nacl | 320 } // namespace nacl |
| OLD | NEW |