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/broker/nacl_broker_listener.h" | 5 #include "components/nacl/broker/nacl_broker_listener.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (!exe_path.empty()) { | 102 if (!exe_path.empty()) { |
103 base::CommandLine* cmd_line = new base::CommandLine(exe_path); | 103 base::CommandLine* cmd_line = new base::CommandLine(exe_path); |
104 nacl::CopyNaClCommandLineArguments(cmd_line); | 104 nacl::CopyNaClCommandLineArguments(cmd_line); |
105 | 105 |
106 cmd_line->AppendSwitchASCII(switches::kProcessType, | 106 cmd_line->AppendSwitchASCII(switches::kProcessType, |
107 switches::kNaClLoaderProcess); | 107 switches::kNaClLoaderProcess); |
108 | 108 |
109 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, | 109 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, |
110 loader_channel_id); | 110 loader_channel_id); |
111 | 111 |
112 base::Process loader_process = content::StartSandboxedProcess( | 112 base::Process loader_process; |
113 this, cmd_line, base::HandlesToInheritVector()); | 113 sandbox::ResultCode result = content::StartSandboxedProcess( |
114 if (loader_process.IsValid()) { | 114 this, cmd_line, base::HandlesToInheritVector(), &loader_process); |
| 115 |
| 116 if (result == sandbox::SBOX_ALL_OK) { |
115 // Note: PROCESS_DUP_HANDLE is necessary here, because: | 117 // Note: PROCESS_DUP_HANDLE is necessary here, because: |
116 // 1) The current process is the broker, which is the loader's parent. | 118 // 1) The current process is the broker, which is the loader's parent. |
117 // 2) The browser is not the loader's parent, and so only gets the | 119 // 2) The browser is not the loader's parent, and so only gets the |
118 // access rights we confer here. | 120 // access rights we confer here. |
119 // 3) The browser calls DuplicateHandle to set up communications with | 121 // 3) The browser calls DuplicateHandle to set up communications with |
120 // the loader. | 122 // the loader. |
121 // 4) The target process handle to DuplicateHandle needs to have | 123 // 4) The target process handle to DuplicateHandle needs to have |
122 // PROCESS_DUP_HANDLE access rights. | 124 // PROCESS_DUP_HANDLE access rights. |
123 DuplicateHandle( | 125 DuplicateHandle( |
124 ::GetCurrentProcess(), loader_process.Handle(), | 126 ::GetCurrentProcess(), loader_process.Handle(), |
(...skipping 12 matching lines...) Expand all Loading... |
137 const std::string& startup_info) { | 139 const std::string& startup_info) { |
138 NaClStartDebugExceptionHandlerThread( | 140 NaClStartDebugExceptionHandlerThread( |
139 base::Process(process_handle), startup_info, | 141 base::Process(process_handle), startup_info, |
140 base::ThreadTaskRunnerHandle::Get(), | 142 base::ThreadTaskRunnerHandle::Get(), |
141 base::Bind(SendReply, channel_.get(), pid)); | 143 base::Bind(SendReply, channel_.get(), pid)); |
142 } | 144 } |
143 | 145 |
144 void NaClBrokerListener::OnStopBroker() { | 146 void NaClBrokerListener::OnStopBroker() { |
145 base::MessageLoop::current()->QuitWhenIdle(); | 147 base::MessageLoop::current()->QuitWhenIdle(); |
146 } | 148 } |
OLD | NEW |