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 "remoting/host/win/wts_console_session_process_driver.h" | 5 #include "remoting/host/win/wts_console_session_process_driver.h" |
6 | 6 |
7 #include <sddl.h> | |
8 #include <limits> | |
9 | |
10 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
11 #include "base/bind.h" | |
12 #include "base/bind_helpers.h" | |
13 #include "base/file_path.h" | 8 #include "base/file_path.h" |
14 #include "base/logging.h" | 9 #include "base/logging.h" |
15 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
16 #include "base/path_service.h" | |
17 #include "ipc/ipc_message.h" | 11 #include "ipc/ipc_message.h" |
| 12 #include "remoting/host/ipc_consts.h" |
18 #include "remoting/host/win/worker_process_launcher.h" | 13 #include "remoting/host/win/worker_process_launcher.h" |
19 #include "remoting/host/win/wts_console_monitor.h" | 14 #include "remoting/host/win/wts_console_monitor.h" |
20 #include "remoting/host/win/wts_session_process_delegate.h" | 15 #include "remoting/host/win/wts_session_process_delegate.h" |
21 | 16 |
22 namespace { | 17 // The security descriptor of the named pipe the process running in the console |
23 | 18 // session connects to. It gives full access to LocalSystem and denies access by |
24 const FilePath::CharType kMe2meHostBinaryName[] = | 19 // anyone else. |
25 FILE_PATH_LITERAL("remoting_host.exe"); | |
26 | |
27 // The security descriptor of the daemon IPC endpoint. It gives full access | |
28 // to LocalSystem and denies access by anyone else. | |
29 const char kDaemonIpcSecurityDescriptor[] = "O:SYG:SYD:(A;;GA;;;SY)"; | 20 const char kDaemonIpcSecurityDescriptor[] = "O:SYG:SYD:(A;;GA;;;SY)"; |
30 | 21 |
31 } // namespace | |
32 | |
33 namespace remoting { | 22 namespace remoting { |
34 | 23 |
35 WtsConsoleSessionProcessDriver::WtsConsoleSessionProcessDriver( | 24 WtsConsoleSessionProcessDriver::WtsConsoleSessionProcessDriver( |
36 const base::Closure& stopped_callback, | 25 const base::Closure& stopped_callback, |
37 WtsConsoleMonitor* monitor, | 26 WtsConsoleMonitor* monitor, |
38 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 27 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
39 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) | 28 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) |
40 : Stoppable(caller_task_runner, stopped_callback), | 29 : Stoppable(caller_task_runner, stopped_callback), |
41 caller_task_runner_(caller_task_runner), | 30 caller_task_runner_(caller_task_runner), |
42 io_task_runner_(io_task_runner), | 31 io_task_runner_(io_task_runner), |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 void WtsConsoleSessionProcessDriver::OnSessionAttached(uint32 session_id) { | 66 void WtsConsoleSessionProcessDriver::OnSessionAttached(uint32 session_id) { |
78 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 67 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
79 | 68 |
80 if (stoppable_state() != Stoppable::kRunning) { | 69 if (stoppable_state() != Stoppable::kRunning) { |
81 return; | 70 return; |
82 } | 71 } |
83 | 72 |
84 DCHECK(launcher_.get() == NULL); | 73 DCHECK(launcher_.get() == NULL); |
85 | 74 |
86 // Construct the host binary name. | 75 // Construct the host binary name. |
87 FilePath dir_path; | 76 FilePath host_binary; |
88 if (!PathService::Get(base::DIR_EXE, &dir_path)) { | 77 if (!GetInstalledBinaryPath(kHostBinaryName, &host_binary)) { |
89 LOG(ERROR) << "Failed to get the executable file name."; | |
90 Stop(); | 78 Stop(); |
91 return; | 79 return; |
92 } | 80 } |
93 FilePath host_binary = dir_path.Append(kMe2meHostBinaryName); | |
94 | 81 |
95 // Create a Delegate capable of launching an elevated process in the session. | 82 // Create a Delegate capable of launching an elevated process in the session. |
96 scoped_ptr<WtsSessionProcessDelegate> delegate( | 83 scoped_ptr<WtsSessionProcessDelegate> delegate( |
97 new WtsSessionProcessDelegate(caller_task_runner_, | 84 new WtsSessionProcessDelegate(caller_task_runner_, |
98 io_task_runner_, | 85 io_task_runner_, |
99 host_binary, | 86 host_binary, |
100 session_id, | 87 session_id, |
101 true)); | 88 true, |
| 89 kDaemonIpcSecurityDescriptor)); |
102 | 90 |
103 // Use the Delegate to launch the host process. | 91 // Use the Delegate to launch the host process. |
104 launcher_.reset(new WorkerProcessLauncher(caller_task_runner_, | 92 launcher_.reset(new WorkerProcessLauncher( |
105 io_task_runner_, | 93 caller_task_runner_, delegate.Pass(), this)); |
106 delegate.Pass(), | |
107 this, | |
108 kDaemonIpcSecurityDescriptor)); | |
109 } | 94 } |
110 | 95 |
111 void WtsConsoleSessionProcessDriver::OnSessionDetached() { | 96 void WtsConsoleSessionProcessDriver::OnSessionDetached() { |
112 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 97 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
113 DCHECK(launcher_.get() != NULL); | 98 DCHECK(launcher_.get() != NULL); |
114 | 99 |
115 launcher_.reset(); | 100 launcher_.reset(); |
116 } | 101 } |
117 | 102 |
118 void WtsConsoleSessionProcessDriver::DoStop() { | 103 void WtsConsoleSessionProcessDriver::DoStop() { |
119 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 104 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
120 | 105 |
121 launcher_.reset(); | 106 launcher_.reset(); |
122 CompleteStopping(); | 107 CompleteStopping(); |
123 } | 108 } |
124 | 109 |
125 } // namespace remoting | 110 } // namespace remoting |
OLD | NEW |