OLD | NEW |
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/win/launch_native_messaging_host_process.h" | 5 #include "remoting/host/win/launch_native_messaging_host_process.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 | 9 |
10 #include <cstdint> | 10 #include <cstdint> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/files/file_util.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/macros.h" | 17 #include "base/macros.h" |
17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
19 #include "base/win/win_util.h" | 20 #include "base/win/win_util.h" |
20 #include "ipc/ipc_channel.h" | 21 #include "ipc/ipc_channel.h" |
21 #include "remoting/host/switches.h" | 22 #include "remoting/host/switches.h" |
22 #include "remoting/host/win/security_descriptor.h" | 23 #include "remoting/host/win/security_descriptor.h" |
23 | 24 |
24 namespace { | 25 namespace { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 61 |
61 ProcessLaunchResult LaunchNativeMessagingHostProcess( | 62 ProcessLaunchResult LaunchNativeMessagingHostProcess( |
62 const base::FilePath& binary_path, | 63 const base::FilePath& binary_path, |
63 intptr_t parent_window_handle, | 64 intptr_t parent_window_handle, |
64 bool elevate_process, | 65 bool elevate_process, |
65 base::win::ScopedHandle* read_handle, | 66 base::win::ScopedHandle* read_handle, |
66 base::win::ScopedHandle* write_handle) { | 67 base::win::ScopedHandle* write_handle) { |
67 DCHECK(read_handle); | 68 DCHECK(read_handle); |
68 DCHECK(write_handle); | 69 DCHECK(write_handle); |
69 | 70 |
| 71 if (!base::PathExists(binary_path)) { |
| 72 LOG(ERROR) << "Cannot find binary: " << binary_path.value(); |
| 73 return PROCESS_LAUNCH_RESULT_FAILED; |
| 74 } |
| 75 |
70 // presubmit: allow wstring | 76 // presubmit: allow wstring |
71 std::wstring user_sid; | 77 std::wstring user_sid; |
72 if (!base::win::GetUserSidString(&user_sid)) { | 78 if (!base::win::GetUserSidString(&user_sid)) { |
73 LOG(ERROR) << "Failed to query the current user SID."; | 79 LOG(ERROR) << "Failed to query the current user SID."; |
74 return PROCESS_LAUNCH_RESULT_FAILED; | 80 return PROCESS_LAUNCH_RESULT_FAILED; |
75 } | 81 } |
76 | 82 |
77 // Create a security descriptor that gives full access to the caller and | 83 // Create a security descriptor that gives full access to the caller and |
78 // BUILTIN_ADMINISTRATORS and denies access by anyone else. | 84 // BUILTIN_ADMINISTRATORS and denies access by anyone else. |
79 // Local admins need access because the privileged host process will run | 85 // Local admins need access because the privileged host process will run |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 return PROCESS_LAUNCH_RESULT_FAILED; | 175 return PROCESS_LAUNCH_RESULT_FAILED; |
170 } | 176 } |
171 } | 177 } |
172 | 178 |
173 read_handle->Set(temp_read_handle.Take()); | 179 read_handle->Set(temp_read_handle.Take()); |
174 write_handle->Set(temp_write_handle.Take()); | 180 write_handle->Set(temp_write_handle.Take()); |
175 return PROCESS_LAUNCH_RESULT_SUCCESS; | 181 return PROCESS_LAUNCH_RESULT_SUCCESS; |
176 } | 182 } |
177 | 183 |
178 } // namespace remoting | 184 } // namespace remoting |
OLD | NEW |