OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/nacl/loader/nacl_listener.h" | 5 #include "components/nacl/loader/nacl_listener.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 | 9 |
10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 #endif | 263 #endif |
264 #if defined(OS_LINUX) || defined(OS_MACOSX) | 264 #if defined(OS_LINUX) || defined(OS_MACOSX) |
265 int urandom_fd = dup(base::GetUrandomFD()); | 265 int urandom_fd = dup(base::GetUrandomFD()); |
266 if (urandom_fd < 0) { | 266 if (urandom_fd < 0) { |
267 LOG(ERROR) << "Failed to dup() the urandom FD"; | 267 LOG(ERROR) << "Failed to dup() the urandom FD"; |
268 return; | 268 return; |
269 } | 269 } |
270 NaClChromeMainSetUrandomFd(urandom_fd); | 270 NaClChromeMainSetUrandomFd(urandom_fd); |
271 #endif | 271 #endif |
272 | 272 |
273 NaClChromeMainInit(); | 273 struct NaClApp* nap = NULL; |
274 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate(); | 274 if (!uses_nonsfi_mode_) { |
275 if (args == NULL) { | 275 NaClChromeMainInit(); |
276 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; | 276 nap = NaClAppCreate(); |
277 return; | 277 if (nap == NULL) { |
278 } | 278 LOG(ERROR) << "NaClAppCreate() failed"; |
279 | 279 return; |
280 struct NaClApp *nap = NaClAppCreate(); | 280 } |
281 if (nap == NULL) { | |
282 LOG(ERROR) << "NaClAppCreate() failed"; | |
283 return; | |
284 } | 281 } |
285 | 282 |
286 IPC::ChannelHandle browser_handle; | 283 IPC::ChannelHandle browser_handle; |
287 IPC::ChannelHandle ppapi_renderer_handle; | 284 IPC::ChannelHandle ppapi_renderer_handle; |
288 | 285 |
289 if (params.enable_ipc_proxy) { | 286 if (params.enable_ipc_proxy) { |
290 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); | 287 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); |
291 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); | 288 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); |
292 | 289 |
293 #if defined(OS_LINUX) | 290 #if defined(OS_LINUX) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 #if defined(OS_POSIX) | 343 #if defined(OS_POSIX) |
347 trusted_renderer_handle.socket = base::FileDescriptor( | 344 trusted_renderer_handle.socket = base::FileDescriptor( |
348 trusted_listener_->TakeClientFileDescriptor(), true); | 345 trusted_listener_->TakeClientFileDescriptor(), true); |
349 #endif | 346 #endif |
350 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( | 347 if (!Send(new NaClProcessHostMsg_PpapiChannelsCreated( |
351 browser_handle, ppapi_renderer_handle, trusted_renderer_handle))) | 348 browser_handle, ppapi_renderer_handle, trusted_renderer_handle))) |
352 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; | 349 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; |
353 | 350 |
354 std::vector<nacl::FileDescriptor> handles = params.handles; | 351 std::vector<nacl::FileDescriptor> handles = params.handles; |
355 | 352 |
| 353 #if defined(OS_LINUX) |
| 354 if (uses_nonsfi_mode_) { |
| 355 if (params.uses_irt) { |
| 356 LOG(ERROR) << "IRT must not be used for non-SFI NaCl."; |
| 357 return; |
| 358 } |
| 359 CHECK(handles.size() == 1); |
| 360 int imc_bootstrap_handle = nacl::ToNativeHandle(handles[0]); |
| 361 nacl::nonsfi::MainStart(imc_bootstrap_handle); |
| 362 return; |
| 363 } |
| 364 #endif |
| 365 |
| 366 struct NaClChromeMainArgs* args = NaClChromeMainArgsCreate(); |
| 367 if (args == NULL) { |
| 368 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; |
| 369 return; |
| 370 } |
| 371 |
356 #if defined(OS_LINUX) || defined(OS_MACOSX) | 372 #if defined(OS_LINUX) || defined(OS_MACOSX) |
357 args->number_of_cores = number_of_cores_; | 373 args->number_of_cores = number_of_cores_; |
358 args->create_memory_object_func = CreateMemoryObject; | 374 args->create_memory_object_func = CreateMemoryObject; |
359 # if defined(OS_MACOSX) | 375 # if defined(OS_MACOSX) |
360 CHECK(handles.size() >= 1); | 376 CHECK(handles.size() >= 1); |
361 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]); | 377 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]); |
362 handles.pop_back(); | 378 handles.pop_back(); |
363 # endif | 379 # endif |
364 #endif | 380 #endif |
365 | 381 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 params.debug_stub_server_bound_socket); | 433 params.debug_stub_server_bound_socket); |
418 #endif | 434 #endif |
419 #if defined(OS_WIN) | 435 #if defined(OS_WIN) |
420 args->broker_duplicate_handle_func = BrokerDuplicateHandle; | 436 args->broker_duplicate_handle_func = BrokerDuplicateHandle; |
421 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; | 437 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; |
422 #endif | 438 #endif |
423 #if defined(OS_LINUX) | 439 #if defined(OS_LINUX) |
424 args->prereserved_sandbox_size = prereserved_sandbox_size_; | 440 args->prereserved_sandbox_size = prereserved_sandbox_size_; |
425 #endif | 441 #endif |
426 | 442 |
427 #if defined(OS_LINUX) | |
428 if (uses_nonsfi_mode_) { | |
429 nacl::nonsfi::MainStart(args->imc_bootstrap_handle); | |
430 return; | |
431 } | |
432 #endif | |
433 NaClChromeMainStartApp(nap, args); | 443 NaClChromeMainStartApp(nap, args); |
434 NOTREACHED(); | 444 NOTREACHED(); |
435 } | 445 } |
OLD | NEW |