| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/common/sandbox_policy.h" | 5 #include "chrome/common/sandbox_policy.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 type = ChildProcessInfo::NACL_BROKER_PROCESS; | 524 type = ChildProcessInfo::NACL_BROKER_PROCESS; |
| 525 } else if (type_str == switches::kGpuProcess) { | 525 } else if (type_str == switches::kGpuProcess) { |
| 526 type = ChildProcessInfo::GPU_PROCESS; | 526 type = ChildProcessInfo::GPU_PROCESS; |
| 527 } else if (type_str == switches::kPpapiPluginProcess) { | 527 } else if (type_str == switches::kPpapiPluginProcess) { |
| 528 type = ChildProcessInfo::PPAPI_PLUGIN_PROCESS; | 528 type = ChildProcessInfo::PPAPI_PLUGIN_PROCESS; |
| 529 } else { | 529 } else { |
| 530 NOTREACHED(); | 530 NOTREACHED(); |
| 531 return 0; | 531 return 0; |
| 532 } | 532 } |
| 533 | 533 |
| 534 TRACE_EVENT_BEGIN("StartProcessWithAccess", 0, type_str); | 534 TRACE_EVENT_BEGIN_LEGACY("StartProcessWithAccess", 0, type_str.c_str()); |
| 535 | 535 |
| 536 // To decide if the process is going to be sandboxed we have two cases. | 536 // To decide if the process is going to be sandboxed we have two cases. |
| 537 // First case: all process types except the nacl broker, gpu process and | 537 // First case: all process types except the nacl broker, gpu process and |
| 538 // the plugin process are sandboxed by default. | 538 // the plugin process are sandboxed by default. |
| 539 bool in_sandbox = | 539 bool in_sandbox = |
| 540 (type != ChildProcessInfo::NACL_BROKER_PROCESS) && | 540 (type != ChildProcessInfo::NACL_BROKER_PROCESS) && |
| 541 (type != ChildProcessInfo::GPU_PROCESS) && | 541 (type != ChildProcessInfo::GPU_PROCESS) && |
| 542 (type != ChildProcessInfo::PLUGIN_PROCESS); | 542 (type != ChildProcessInfo::PLUGIN_PROCESS); |
| 543 | 543 |
| 544 // Second case: If it is the plugin process then it depends on it being | 544 // Second case: If it is the plugin process then it depends on it being |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 exposed_files.value().c_str()); | 621 exposed_files.value().c_str()); |
| 622 if (result != sandbox::SBOX_ALL_OK) | 622 if (result != sandbox::SBOX_ALL_OK) |
| 623 return 0; | 623 return 0; |
| 624 } | 624 } |
| 625 | 625 |
| 626 if (!AddGenericPolicy(policy)) { | 626 if (!AddGenericPolicy(policy)) { |
| 627 NOTREACHED(); | 627 NOTREACHED(); |
| 628 return 0; | 628 return 0; |
| 629 } | 629 } |
| 630 | 630 |
| 631 TRACE_EVENT_BEGIN("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); | 631 TRACE_EVENT_BEGIN_LEGACY("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); |
| 632 | 632 |
| 633 result = g_broker_services->SpawnTarget( | 633 result = g_broker_services->SpawnTarget( |
| 634 cmd_line->GetProgram().value().c_str(), | 634 cmd_line->GetProgram().value().c_str(), |
| 635 cmd_line->command_line_string().c_str(), | 635 cmd_line->command_line_string().c_str(), |
| 636 policy, &target); | 636 policy, &target); |
| 637 policy->Release(); | 637 policy->Release(); |
| 638 | 638 |
| 639 TRACE_EVENT_END("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); | 639 TRACE_EVENT_END_LEGACY("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); |
| 640 | 640 |
| 641 if (sandbox::SBOX_ALL_OK != result) | 641 if (sandbox::SBOX_ALL_OK != result) |
| 642 return 0; | 642 return 0; |
| 643 | 643 |
| 644 ResumeThread(target.hThread); | 644 ResumeThread(target.hThread); |
| 645 CloseHandle(target.hThread); | 645 CloseHandle(target.hThread); |
| 646 process = target.hProcess; | 646 process = target.hProcess; |
| 647 | 647 |
| 648 // Help the process a little. It can't start the debugger by itself if | 648 // Help the process a little. It can't start the debugger by itself if |
| 649 // the process is in a sandbox. | 649 // the process is in a sandbox. |
| 650 if (child_needs_help) | 650 if (child_needs_help) |
| 651 base::debug::SpawnDebuggerOnProcess(target.dwProcessId); | 651 base::debug::SpawnDebuggerOnProcess(target.dwProcessId); |
| 652 | 652 |
| 653 return process; | 653 return process; |
| 654 } | 654 } |
| 655 | 655 |
| 656 } // namespace sandbox | 656 } // namespace sandbox |
| OLD | NEW |