Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: remoting/host/security_key/security_key_ipc_server_impl.cc

Issue 2468523003: Pass the desktop session ID to the remoting network process. (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "remoting/host/security_key/security_key_ipc_server_impl.h" 5 #include "remoting/host/security_key/security_key_ipc_server_impl.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 #include "ipc/ipc_channel.h" 17 #include "ipc/ipc_channel.h"
18 #include "ipc/ipc_message.h" 18 #include "ipc/ipc_message.h"
19 #include "ipc/ipc_message_macros.h" 19 #include "ipc/ipc_message_macros.h"
20 #include "remoting/base/logging.h" 20 #include "remoting/base/logging.h"
21 #include "remoting/host/chromoting_messages.h" 21 #include "remoting/host/chromoting_messages.h"
22 #include "remoting/host/client_session_details.h"
22 23
23 #if defined(OS_WIN) 24 #if defined(OS_WIN)
24 #include "base/strings/stringprintf.h" 25 #include "base/strings/stringprintf.h"
25 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
26 #include "base/win/win_util.h" 27 #include "base/win/win_util.h"
27 #include "remoting/host/ipc_util.h" 28 #include "remoting/host/ipc_util.h"
28 #endif // defined(OS_WIN) 29 #endif // defined(OS_WIN)
29 30
30 namespace { 31 namespace {
31 32
32 // Returns the command code (the first byte of the data) if it exists, or -1 if 33 // Returns the command code (the first byte of the data) if it exists, or -1 if
33 // the data is empty. 34 // the data is empty.
34 unsigned int GetCommandCode(const std::string& data) { 35 unsigned int GetCommandCode(const std::string& data) {
35 return data.empty() ? -1 : static_cast<unsigned int>(data[0]); 36 return data.empty() ? -1 : static_cast<unsigned int>(data[0]);
36 } 37 }
37 38
38 } // namespace 39 } // namespace
39 40
40 namespace remoting { 41 namespace remoting {
41 42
42 SecurityKeyIpcServerImpl::SecurityKeyIpcServerImpl( 43 SecurityKeyIpcServerImpl::SecurityKeyIpcServerImpl(
43 int connection_id, 44 int connection_id,
44 uint32_t peer_session_id, 45 ClientSessionDetails* client_session_details,
45 base::TimeDelta initial_connect_timeout, 46 base::TimeDelta initial_connect_timeout,
46 const SecurityKeyAuthHandler::SendMessageCallback& message_callback, 47 const SecurityKeyAuthHandler::SendMessageCallback& message_callback,
47 const base::Closure& done_callback) 48 const base::Closure& done_callback)
48 : connection_id_(connection_id), 49 : connection_id_(connection_id),
49 peer_session_id_(peer_session_id), 50 client_session_details_(client_session_details),
50 initial_connect_timeout_(initial_connect_timeout), 51 initial_connect_timeout_(initial_connect_timeout),
51 done_callback_(done_callback), 52 done_callback_(done_callback),
52 message_callback_(message_callback), 53 message_callback_(message_callback),
53 weak_factory_(this) { 54 weak_factory_(this) {
54 DCHECK_GT(connection_id_, 0); 55 DCHECK_GT(connection_id_, 0);
55 DCHECK(!done_callback_.is_null()); 56 DCHECK(!done_callback_.is_null());
56 DCHECK(!message_callback_.is_null()); 57 DCHECK(!message_callback_.is_null());
57 } 58 }
58 59
59 SecurityKeyIpcServerImpl::~SecurityKeyIpcServerImpl() {} 60 SecurityKeyIpcServerImpl::~SecurityKeyIpcServerImpl() {}
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 137 }
137 138
138 void SecurityKeyIpcServerImpl::OnChannelConnected(int32_t peer_pid) { 139 void SecurityKeyIpcServerImpl::OnChannelConnected(int32_t peer_pid) {
139 DCHECK(thread_checker_.CalledOnValidThread()); 140 DCHECK(thread_checker_.CalledOnValidThread());
140 141
141 #if defined(OS_WIN) 142 #if defined(OS_WIN)
142 DWORD peer_session_id; 143 DWORD peer_session_id;
143 if (!ProcessIdToSessionId(peer_pid, &peer_session_id)) { 144 if (!ProcessIdToSessionId(peer_pid, &peer_session_id)) {
144 PLOG(ERROR) << "ProcessIdToSessionId() failed"; 145 PLOG(ERROR) << "ProcessIdToSessionId() failed";
145 connection_close_pending_ = true; 146 connection_close_pending_ = true;
146 } else if (peer_session_id != peer_session_id_) { 147 } else if (peer_session_id != client_session_details_->desktop_session_id()) {
147 LOG(ERROR) << "Ignoring connection attempt from outside remoted session."; 148 LOG(ERROR) << "Ignoring connection attempt from outside remoted session.";
148 connection_close_pending_ = true; 149 connection_close_pending_ = true;
149 } 150 }
150 if (connection_close_pending_) { 151 if (connection_close_pending_) {
151 base::ThreadTaskRunnerHandle::Get()->PostTask( 152 base::ThreadTaskRunnerHandle::Get()->PostTask(
152 FROM_HERE, base::Bind(&SecurityKeyIpcServerImpl::OnChannelError, 153 FROM_HERE, base::Bind(&SecurityKeyIpcServerImpl::OnChannelError,
153 weak_factory_.GetWeakPtr())); 154 weak_factory_.GetWeakPtr()));
154 return; 155 return;
155 } 156 }
156 #else // !defined(OS_WIN) 157 #else // !defined(OS_WIN)
157 CHECK_EQ(peer_session_id_, UINT32_MAX); 158 CHECK_EQ(client_session_details_->desktop_session_id(), UINT32_MAX);
158 #endif // !defined(OS_WIN) 159 #endif // !defined(OS_WIN)
159 160
160 // Reset the timer to give the client a chance to send the request. 161 // Reset the timer to give the client a chance to send the request.
161 timer_.Start(FROM_HERE, initial_connect_timeout_, 162 timer_.Start(FROM_HERE, initial_connect_timeout_,
162 base::Bind(&SecurityKeyIpcServerImpl::OnChannelError, 163 base::Bind(&SecurityKeyIpcServerImpl::OnChannelError,
163 base::Unretained(this))); 164 base::Unretained(this)));
164 } 165 }
165 166
166 void SecurityKeyIpcServerImpl::OnChannelError() { 167 void SecurityKeyIpcServerImpl::OnChannelError() {
167 DCHECK(thread_checker_.CalledOnValidThread()); 168 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 15 matching lines...) Expand all
183 // Reset the timer to give the client a chance to send the response. 184 // Reset the timer to give the client a chance to send the response.
184 timer_.Start(FROM_HERE, security_key_request_timeout_, 185 timer_.Start(FROM_HERE, security_key_request_timeout_,
185 base::Bind(&SecurityKeyIpcServerImpl::OnChannelError, 186 base::Bind(&SecurityKeyIpcServerImpl::OnChannelError,
186 base::Unretained(this))); 187 base::Unretained(this)));
187 188
188 HOST_LOG << "Received security key request: " << GetCommandCode(request_data); 189 HOST_LOG << "Received security key request: " << GetCommandCode(request_data);
189 message_callback_.Run(connection_id_, request_data); 190 message_callback_.Run(connection_id_, request_data);
190 } 191 }
191 192
192 } // namespace remoting 193 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698