| 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(); |
| 731 base::win::ScopedProcessInformation target(temp_process_info); | 732 base::win::ScopedProcessInformation target(temp_process_info); |
| 732 | 733 |
| 733 TRACE_EVENT_END_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); | 734 TRACE_EVENT_END_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); |
| 734 | 735 |
| 735 if (sandbox::SBOX_ALL_OK != result) { | 736 if (sandbox::SBOX_ALL_OK != result) { |
| 736 if (result == sandbox::SBOX_ERROR_GENERIC) | 737 if (result == sandbox::SBOX_ERROR_GENERIC) |
| 737 DPLOG(ERROR) << "Failed to launch process"; | 738 DPLOG(ERROR) << "Failed to launch process"; |
| 738 else if (result == sandbox::SBOX_ERROR_CREATE_PROCESS) { | 739 else if (result == sandbox::SBOX_ERROR_CREATE_PROCESS) { |
| 739 // TODO(shrikant): Remove this special case handling after determining | 740 // TODO(shrikant): Remove this special case handling after determining |
| 740 // cause for lowbox/createprocess errors. | 741 // cause for lowbox/createprocess errors. |
| 741 sandbox::PolicyBase* policy_base = | 742 sandbox::PolicyBase* policy_base = |
| 742 static_cast<sandbox::PolicyBase*>(policy); | 743 static_cast<sandbox::PolicyBase*>(policy); |
| 743 UMA_HISTOGRAM_SPARSE_SLOWLY(policy_base->GetLowBoxSid() ? | 744 UMA_HISTOGRAM_SPARSE_SLOWLY(policy_base->GetLowBoxSid() ? |
| 744 "Process.Sandbox.Lowbox.Launch.Error" : | 745 "Process.Sandbox.Lowbox.Launch.Error" : |
| 745 "Process.Sandbox.Launch.Error", | 746 "Process.Sandbox.Launch.Error", |
| 746 last_error); | 747 last_error); |
| 747 } else | 748 } else |
| 748 DLOG(ERROR) << "Failed to launch process. Error: " << result; | 749 DLOG(ERROR) << "Failed to launch process. Error: " << result; |
| 749 | |
| 750 policy->Release(); | |
| 751 return base::Process(); | 750 return base::Process(); |
| 752 } | 751 } |
| 753 policy->Release(); | |
| 754 | 752 |
| 755 if (delegate) | 753 if (delegate) |
| 756 delegate->PostSpawnTarget(target.process_handle()); | 754 delegate->PostSpawnTarget(target.process_handle()); |
| 757 | 755 |
| 758 CHECK(ResumeThread(target.thread_handle()) != -1); | 756 CHECK(ResumeThread(target.thread_handle()) != -1); |
| 759 TRACE_EVENT_END_ETW("StartProcessWithAccess", 0, type_str); | 757 TRACE_EVENT_END_ETW("StartProcessWithAccess", 0, type_str); |
| 760 return base::Process(target.TakeProcessHandle()); | 758 return base::Process(target.TakeProcessHandle()); |
| 761 } | 759 } |
| 762 | 760 |
| 763 bool BrokerDuplicateHandle(HANDLE source_handle, | 761 bool BrokerDuplicateHandle(HANDLE source_handle, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 792 } | 790 } |
| 793 | 791 |
| 794 return false; | 792 return false; |
| 795 } | 793 } |
| 796 | 794 |
| 797 bool BrokerAddTargetPeer(HANDLE peer_process) { | 795 bool BrokerAddTargetPeer(HANDLE peer_process) { |
| 798 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 796 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
| 799 } | 797 } |
| 800 | 798 |
| 801 } // namespace content | 799 } // namespace content |
| OLD | NEW |