| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/common/sandbox_win.h" | 5 #include "content/common/sandbox_win.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 } | 721 } |
| 722 | 722 |
| 723 TRACE_EVENT_BEGIN_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); | 723 TRACE_EVENT_BEGIN_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); |
| 724 | 724 |
| 725 PROCESS_INFORMATION temp_process_info = {}; | 725 PROCESS_INFORMATION temp_process_info = {}; |
| 726 result = g_broker_services->SpawnTarget( | 726 result = g_broker_services->SpawnTarget( |
| 727 cmd_line->GetProgram().value().c_str(), | 727 cmd_line->GetProgram().value().c_str(), |
| 728 cmd_line->GetCommandLineString().c_str(), | 728 cmd_line->GetCommandLineString().c_str(), |
| 729 policy, &temp_process_info); | 729 policy, &temp_process_info); |
| 730 DWORD last_error = ::GetLastError(); | 730 DWORD last_error = ::GetLastError(); |
| 731 policy->Release(); | |
| 732 base::win::ScopedProcessInformation target(temp_process_info); | 731 base::win::ScopedProcessInformation target(temp_process_info); |
| 733 | 732 |
| 734 TRACE_EVENT_END_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); | 733 TRACE_EVENT_END_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); |
| 735 | 734 |
| 736 if (sandbox::SBOX_ALL_OK != result) { | 735 if (sandbox::SBOX_ALL_OK != result) { |
| 737 if (result == sandbox::SBOX_ERROR_GENERIC) | 736 if (result == sandbox::SBOX_ERROR_GENERIC) |
| 738 DPLOG(ERROR) << "Failed to launch process"; | 737 DPLOG(ERROR) << "Failed to launch process"; |
| 739 else if (result == sandbox::SBOX_ERROR_CREATE_PROCESS) { | 738 else if (result == sandbox::SBOX_ERROR_CREATE_PROCESS) { |
| 740 // TODO(shrikant): Remove this special case handling after determining | 739 // TODO(shrikant): Remove this special case handling after determining |
| 741 // cause for lowbox/createprocess errors. | 740 // cause for lowbox/createprocess errors. |
| 742 sandbox::PolicyBase* policy_base = | 741 sandbox::PolicyBase* policy_base = |
| 743 static_cast<sandbox::PolicyBase*>(policy); | 742 static_cast<sandbox::PolicyBase*>(policy); |
| 744 UMA_HISTOGRAM_SPARSE_SLOWLY(policy_base->GetLowBoxSid() ? | 743 UMA_HISTOGRAM_SPARSE_SLOWLY(policy_base->GetLowBoxSid() ? |
| 745 "Process.Sandbox.Lowbox.Launch.Error" : | 744 "Process.Sandbox.Lowbox.Launch.Error" : |
| 746 "Process.Sandbox.Launch.Error", | 745 "Process.Sandbox.Launch.Error", |
| 747 last_error); | 746 last_error); |
| 748 } else | 747 } else |
| 749 DLOG(ERROR) << "Failed to launch process. Error: " << result; | 748 DLOG(ERROR) << "Failed to launch process. Error: " << result; |
| 749 |
| 750 policy->Release(); |
| 750 return base::Process(); | 751 return base::Process(); |
| 751 } | 752 } |
| 753 policy->Release(); |
| 752 | 754 |
| 753 if (delegate) | 755 if (delegate) |
| 754 delegate->PostSpawnTarget(target.process_handle()); | 756 delegate->PostSpawnTarget(target.process_handle()); |
| 755 | 757 |
| 756 CHECK(ResumeThread(target.thread_handle()) != -1); | 758 CHECK(ResumeThread(target.thread_handle()) != -1); |
| 757 TRACE_EVENT_END_ETW("StartProcessWithAccess", 0, type_str); | 759 TRACE_EVENT_END_ETW("StartProcessWithAccess", 0, type_str); |
| 758 return base::Process(target.TakeProcessHandle()); | 760 return base::Process(target.TakeProcessHandle()); |
| 759 } | 761 } |
| 760 | 762 |
| 761 bool BrokerDuplicateHandle(HANDLE source_handle, | 763 bool BrokerDuplicateHandle(HANDLE source_handle, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 790 } | 792 } |
| 791 | 793 |
| 792 return false; | 794 return false; |
| 793 } | 795 } |
| 794 | 796 |
| 795 bool BrokerAddTargetPeer(HANDLE peer_process) { | 797 bool BrokerAddTargetPeer(HANDLE peer_process) { |
| 796 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 798 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
| 797 } | 799 } |
| 798 | 800 |
| 799 } // namespace content | 801 } // namespace content |
| OLD | NEW |