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 #ifndef REMOTING_HOST_WIN_LAUNCH_PROCESS_WITH_TOKEN_H_ | 5 #ifndef REMOTING_HOST_WIN_LAUNCH_PROCESS_WITH_TOKEN_H_ |
6 #define REMOTING_HOST_WIN_LAUNCH_PROCESS_WITH_TOKEN_H_ | 6 #define REMOTING_HOST_WIN_LAUNCH_PROCESS_WITH_TOKEN_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/win/scoped_handle.h" | 15 #include "base/win/scoped_handle.h" |
16 | 16 |
| 17 namespace base { |
| 18 class SingleThreadTaskRunner; |
| 19 } // namespace base |
| 20 |
| 21 namespace IPC { |
| 22 class ChannelProxy; |
| 23 class Listener; |
| 24 } // namespace IPC |
| 25 |
17 namespace remoting { | 26 namespace remoting { |
18 | 27 |
19 // Pipe name prefix used by Chrome IPC channels to convert a channel name into | 28 // Pipe name prefix used by Chrome IPC channels to convert a channel name into |
20 // a pipe name. | 29 // a pipe name. |
21 extern const char kChromePipeNamePrefix[]; | 30 extern const char kChromePipeNamePrefix[]; |
22 | 31 |
| 32 // Creates an already connected IPC channel. The server end of the channel |
| 33 // is wrapped into a channel proxy that will invoke methods of |delegate| |
| 34 // on the caller's thread while using |io_task_runner| to send and receive |
| 35 // messages in the background. The client end is returned as an inheritable NT |
| 36 // handle. |pipe_security_descriptor| is applied to the underlying pipe. |
| 37 bool CreateConnectedIpcChannel( |
| 38 const std::string& channel_name, |
| 39 const std::string& pipe_security_descriptor, |
| 40 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| 41 IPC::Listener* delegate, |
| 42 base::win::ScopedHandle* client_out, |
| 43 scoped_ptr<IPC::ChannelProxy>* server_out); |
| 44 |
23 // Creates the server end of the IPC channel and applies the security | 45 // Creates the server end of the IPC channel and applies the security |
24 // descriptor |pipe_security_descriptor| to it. | 46 // descriptor |pipe_security_descriptor| to it. |
25 bool CreateIpcChannel( | 47 bool CreateIpcChannel( |
26 const std::string& channel_name, | 48 const std::string& channel_name, |
27 const std::string& pipe_security_descriptor, | 49 const std::string& pipe_security_descriptor, |
28 base::win::ScopedHandle* pipe_out); | 50 base::win::ScopedHandle* pipe_out); |
29 | 51 |
30 // Creates a copy of the current process token for the given |session_id| so | 52 // Creates a copy of the current process token for the given |session_id| so |
31 // it can be used to launch a process in that session. | 53 // it can be used to launch a process in that session. |
32 bool CreateSessionToken(uint32 session_id, base::win::ScopedHandle* token_out); | 54 bool CreateSessionToken(uint32 session_id, base::win::ScopedHandle* token_out); |
33 | 55 |
34 // Generates a unique IPC channel name. | |
35 std::string GenerateIpcChannelName(void* client); | |
36 | |
37 // Launches |binary| in the security context of the user represented by | 56 // Launches |binary| in the security context of the user represented by |
38 // |user_token|. The session ID specified by the token is respected as well. | 57 // |user_token|. The session ID specified by the token is respected as well. |
39 bool LaunchProcessWithToken(const FilePath& binary, | 58 bool LaunchProcessWithToken(const FilePath& binary, |
40 const CommandLine::StringType& command_line, | 59 const CommandLine::StringType& command_line, |
41 HANDLE user_token, | 60 HANDLE user_token, |
42 bool inherit_handles, | 61 bool inherit_handles, |
43 DWORD creation_flags, | 62 DWORD creation_flags, |
44 base::win::ScopedHandle* process_out, | 63 base::win::ScopedHandle* process_out, |
45 base::win::ScopedHandle* thread_out); | 64 base::win::ScopedHandle* thread_out); |
46 | 65 |
47 } // namespace remoting | 66 } // namespace remoting |
48 | 67 |
49 #endif // REMOTING_HOST_WIN_LAUNCH_PROCESS_WITH_TOKEN_H_ | 68 #endif // REMOTING_HOST_WIN_LAUNCH_PROCESS_WITH_TOKEN_H_ |
OLD | NEW |