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 "remoting/host/setup/daemon_controller_delegate_linux.h" | 5 #include "remoting/host/setup/daemon_controller_delegate_linux.h" |
6 | 6 |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/environment.h" | 14 #include "base/environment.h" |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
17 #include "base/json/json_writer.h" | 17 #include "base/json/json_writer.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/md5.h" | 19 #include "base/md5.h" |
20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
21 #include "base/process/kill.h" | 21 #include "base/process/kill.h" |
22 #include "base/process/launch.h" | 22 #include "base/process/launch.h" |
23 #include "base/process/process_handle.h" | 23 #include "base/process/process_handle.h" |
24 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
25 #include "base/strings/string_split.h" | 25 #include "base/strings/string_split.h" |
26 #include "base/strings/string_util.h" | 26 #include "base/strings/string_util.h" |
27 #include "base/thread_task_runner_handle.h" | 27 #include "base/thread_task_runner_handle.h" |
28 #include "base/values.h" | 28 #include "base/values.h" |
| 29 #include "build/build_config.h" |
29 #include "net/base/net_util.h" | 30 #include "net/base/net_util.h" |
30 #include "remoting/host/host_config.h" | 31 #include "remoting/host/host_config.h" |
31 #include "remoting/host/json_host_config.h" | 32 #include "remoting/host/json_host_config.h" |
32 #include "remoting/host/usage_stats_consent.h" | 33 #include "remoting/host/usage_stats_consent.h" |
33 | 34 |
34 namespace remoting { | 35 namespace remoting { |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 const char kDaemonScript[] = | 39 const char kDaemonScript[] = |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 95 } |
95 base::ProcessHandle process_handle; | 96 base::ProcessHandle process_handle; |
96 | 97 |
97 // Redirect the child's stdout to the parent's stderr. In the case where this | 98 // Redirect the child's stdout to the parent's stderr. In the case where this |
98 // parent process is a Native Messaging host, its stdout is used to send | 99 // parent process is a Native Messaging host, its stdout is used to send |
99 // messages to the web-app. | 100 // messages to the web-app. |
100 base::FileHandleMappingVector fds_to_remap; | 101 base::FileHandleMappingVector fds_to_remap; |
101 fds_to_remap.push_back(std::pair<int, int>(STDERR_FILENO, STDOUT_FILENO)); | 102 fds_to_remap.push_back(std::pair<int, int>(STDERR_FILENO, STDOUT_FILENO)); |
102 base::LaunchOptions options; | 103 base::LaunchOptions options; |
103 options.fds_to_remap = &fds_to_remap; | 104 options.fds_to_remap = &fds_to_remap; |
| 105 |
| 106 #if !defined(OS_CHROMEOS) |
| 107 options.allow_new_privs = true; |
| 108 #endif |
| 109 |
104 if (!base::LaunchProcess(command_line, options, &process_handle)) { | 110 if (!base::LaunchProcess(command_line, options, &process_handle)) { |
105 LOG(ERROR) << "Failed to run command: " | 111 LOG(ERROR) << "Failed to run command: " |
106 << command_line.GetCommandLineString(); | 112 << command_line.GetCommandLineString(); |
107 return false; | 113 return false; |
108 } | 114 } |
109 | 115 |
110 if (!base::WaitForExitCodeWithTimeout(process_handle, exit_code, timeout)) { | 116 if (!base::WaitForExitCodeWithTimeout(process_handle, exit_code, timeout)) { |
111 base::KillProcess(process_handle, 0, false); | 117 base::KillProcess(process_handle, 0, false); |
112 LOG(ERROR) << "Timeout exceeded for command: " | 118 LOG(ERROR) << "Timeout exceeded for command: " |
113 << command_line.GetCommandLineString(); | 119 << command_line.GetCommandLineString(); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 return consent; | 324 return consent; |
319 } | 325 } |
320 | 326 |
321 scoped_refptr<DaemonController> DaemonController::Create() { | 327 scoped_refptr<DaemonController> DaemonController::Create() { |
322 scoped_ptr<DaemonController::Delegate> delegate( | 328 scoped_ptr<DaemonController::Delegate> delegate( |
323 new DaemonControllerDelegateLinux()); | 329 new DaemonControllerDelegateLinux()); |
324 return new DaemonController(delegate.Pass()); | 330 return new DaemonController(delegate.Pass()); |
325 } | 331 } |
326 | 332 |
327 } // namespace remoting | 333 } // namespace remoting |
OLD | NEW |