| 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" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/process/process.h" | 12 #include "base/process/process.h" |
| 13 #include "base/process/process_handle.h" | 13 #include "base/process/process_handle.h" |
| 14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
| 15 #include "components/nacl/common/nacl_cmd_line.h" | 15 #include "components/nacl/common/nacl_cmd_line.h" |
| 16 #include "components/nacl/common/nacl_debug_exception_handler_win.h" | 16 #include "components/nacl/common/nacl_debug_exception_handler_win.h" |
| 17 #include "components/nacl/common/nacl_messages.h" | 17 #include "components/nacl/common/nacl_messages.h" |
| 18 #include "components/nacl/common/nacl_switches.h" | 18 #include "components/nacl/common/nacl_switches.h" |
| 19 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
| 20 #include "content/public/common/sandbox_init.h" | 20 #include "content/public/common/sandbox_init.h" |
| 21 #include "ipc/attachment_broker_unprivileged.h" | 21 #include "ipc/attachment_broker_unprivileged.h" |
| 22 #include "ipc/ipc_channel.h" | 22 #include "ipc/ipc_channel.h" |
| 23 #include "ipc/ipc_switches.h" | 23 #include "ipc/ipc_switches.h" |
| 24 #include "sandbox/win/src/sandbox_policy.h" | 24 #include "sandbox/win/src/sandbox_policy.h" |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 void SendReply(IPC::Channel* channel, int32 pid, bool result) { | 28 void SendReply(IPC::Channel* channel, int32_t pid, bool result) { |
| 29 channel->Send(new NaClProcessMsg_DebugExceptionHandlerLaunched(pid, result)); | 29 channel->Send(new NaClProcessMsg_DebugExceptionHandlerLaunched(pid, result)); |
| 30 } | 30 } |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 NaClBrokerListener::NaClBrokerListener() { | 34 NaClBrokerListener::NaClBrokerListener() { |
| 35 attachment_broker_.reset( | 35 attachment_broker_.reset( |
| 36 IPC::AttachmentBrokerUnprivileged::CreateBroker().release()); | 36 IPC::AttachmentBrokerUnprivileged::CreateBroker().release()); |
| 37 } | 37 } |
| 38 | 38 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 57 // Allow the server side of a pipe restricted to the "chrome.nacl." | 57 // Allow the server side of a pipe restricted to the "chrome.nacl." |
| 58 // namespace so that it cannot impersonate other system or other chrome | 58 // namespace so that it cannot impersonate other system or other chrome |
| 59 // service pipes. | 59 // service pipes. |
| 60 sandbox::ResultCode result = policy->AddRule( | 60 sandbox::ResultCode result = policy->AddRule( |
| 61 sandbox::TargetPolicy::SUBSYS_NAMED_PIPES, | 61 sandbox::TargetPolicy::SUBSYS_NAMED_PIPES, |
| 62 sandbox::TargetPolicy::NAMEDPIPES_ALLOW_ANY, | 62 sandbox::TargetPolicy::NAMEDPIPES_ALLOW_ANY, |
| 63 L"\\\\.\\pipe\\chrome.nacl.*"); | 63 L"\\\\.\\pipe\\chrome.nacl.*"); |
| 64 return result == sandbox::SBOX_ALL_OK; | 64 return result == sandbox::SBOX_ALL_OK; |
| 65 } | 65 } |
| 66 | 66 |
| 67 void NaClBrokerListener::OnChannelConnected(int32 peer_pid) { | 67 void NaClBrokerListener::OnChannelConnected(int32_t peer_pid) { |
| 68 browser_process_ = base::Process::OpenWithExtraPrivileges(peer_pid); | 68 browser_process_ = base::Process::OpenWithExtraPrivileges(peer_pid); |
| 69 CHECK(browser_process_.IsValid()); | 69 CHECK(browser_process_.IsValid()); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool NaClBrokerListener::OnMessageReceived(const IPC::Message& msg) { | 72 bool NaClBrokerListener::OnMessageReceived(const IPC::Message& msg) { |
| 73 bool handled = true; | 73 bool handled = true; |
| 74 IPC_BEGIN_MESSAGE_MAP(NaClBrokerListener, msg) | 74 IPC_BEGIN_MESSAGE_MAP(NaClBrokerListener, msg) |
| 75 IPC_MESSAGE_HANDLER(NaClProcessMsg_LaunchLoaderThroughBroker, | 75 IPC_MESSAGE_HANDLER(NaClProcessMsg_LaunchLoaderThroughBroker, |
| 76 OnLaunchLoaderThroughBroker) | 76 OnLaunchLoaderThroughBroker) |
| 77 IPC_MESSAGE_HANDLER(NaClProcessMsg_LaunchDebugExceptionHandler, | 77 IPC_MESSAGE_HANDLER(NaClProcessMsg_LaunchDebugExceptionHandler, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 browser_process_.Handle(), &loader_handle_in_browser, | 121 browser_process_.Handle(), &loader_handle_in_browser, |
| 122 PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION | PROCESS_TERMINATE, | 122 PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION | PROCESS_TERMINATE, |
| 123 FALSE, 0); | 123 FALSE, 0); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 channel_->Send(new NaClProcessMsg_LoaderLaunched(loader_channel_id, | 126 channel_->Send(new NaClProcessMsg_LoaderLaunched(loader_channel_id, |
| 127 loader_handle_in_browser)); | 127 loader_handle_in_browser)); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void NaClBrokerListener::OnLaunchDebugExceptionHandler( | 130 void NaClBrokerListener::OnLaunchDebugExceptionHandler( |
| 131 int32 pid, base::ProcessHandle process_handle, | 131 int32_t pid, |
| 132 base::ProcessHandle process_handle, |
| 132 const std::string& startup_info) { | 133 const std::string& startup_info) { |
| 133 NaClStartDebugExceptionHandlerThread( | 134 NaClStartDebugExceptionHandlerThread( |
| 134 base::Process(process_handle), startup_info, | 135 base::Process(process_handle), startup_info, |
| 135 base::ThreadTaskRunnerHandle::Get(), | 136 base::ThreadTaskRunnerHandle::Get(), |
| 136 base::Bind(SendReply, channel_.get(), pid)); | 137 base::Bind(SendReply, channel_.get(), pid)); |
| 137 } | 138 } |
| 138 | 139 |
| 139 void NaClBrokerListener::OnStopBroker() { | 140 void NaClBrokerListener::OnStopBroker() { |
| 140 base::MessageLoop::current()->QuitWhenIdle(); | 141 base::MessageLoop::current()->QuitWhenIdle(); |
| 141 } | 142 } |
| OLD | NEW |