| Index: remoting/host/ipc_util_win.cc
|
| diff --git a/remoting/host/ipc_util_win.cc b/remoting/host/ipc_util_win.cc
|
| index f7f57a6cb8e6271f9036c68ab1ec4dca8dce7d34..a70b528fdeea7448aa9ad0eaf27f1b34db7593fa 100644
|
| --- a/remoting/host/ipc_util_win.cc
|
| +++ b/remoting/host/ipc_util_win.cc
|
| @@ -6,96 +6,19 @@
|
|
|
| #include <utility>
|
|
|
| -#include "base/files/file.h"
|
| #include "base/logging.h"
|
| -#include "base/single_thread_task_runner.h"
|
| -#include "base/strings/stringprintf.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/win/scoped_handle.h"
|
| #include "base/win/win_util.h"
|
| -#include "ipc/attachment_broker.h"
|
| #include "ipc/ipc_channel.h"
|
| -#include "ipc/ipc_channel_proxy.h"
|
| #include "remoting/host/win/security_descriptor.h"
|
|
|
| -using base::win::ScopedHandle;
|
| -
|
| namespace remoting {
|
|
|
| // Pipe name prefix used by Chrome IPC channels to convert a channel name into
|
| // a pipe name.
|
| const char kChromePipeNamePrefix[] = "\\\\.\\pipe\\chrome.";
|
|
|
| -bool CreateConnectedIpcChannel(
|
| - scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
|
| - IPC::Listener* listener,
|
| - base::File* client_out,
|
| - std::unique_ptr<IPC::ChannelProxy>* server_out) {
|
| - // presubmit: allow wstring
|
| - std::wstring user_sid;
|
| - if (!base::win::GetUserSidString(&user_sid)) {
|
| - LOG(ERROR) << "Failed to query the current user SID.";
|
| - return false;
|
| - }
|
| -
|
| - // Create a security descriptor that will be used to protect the named pipe in
|
| - // between CreateNamedPipe() and CreateFile() calls before it will be passed
|
| - // to the network process. It gives full access to the account that
|
| - // the calling code is running under and denies access by anyone else.
|
| - std::string user_sid_utf8 = base::WideToUTF8(user_sid);
|
| - std::string security_descriptor =
|
| - base::StringPrintf("O:%sG:%sD:(A;;GA;;;%s)", user_sid_utf8.c_str(),
|
| - user_sid_utf8.c_str(), user_sid_utf8.c_str());
|
| -
|
| - // Generate a unique name for the channel.
|
| - std::string channel_name = IPC::Channel::GenerateUniqueRandomChannelID();
|
| -
|
| - // Create the server end of the channel.
|
| - ScopedHandle pipe;
|
| - if (!CreateIpcChannel(channel_name, security_descriptor, &pipe)) {
|
| - return false;
|
| - }
|
| -
|
| - // Wrap the pipe into an IPC channel.
|
| - std::unique_ptr<IPC::ChannelProxy> server(
|
| - new IPC::ChannelProxy(listener, io_task_runner));
|
| - IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
|
| - DCHECK(broker) << "No AttachmentBroker registered.";
|
| - if (broker->IsPrivilegedBroker()) {
|
| - broker->RegisterCommunicationChannel(server.get(), io_task_runner);
|
| - }
|
| - server->Init(IPC::ChannelHandle(pipe.Get()), IPC::Channel::MODE_SERVER,
|
| - /*create_pipe_now=*/true);
|
| -
|
| - // Convert the channel name to the pipe name.
|
| - std::string pipe_name(kChromePipeNamePrefix);
|
| - pipe_name.append(channel_name);
|
| -
|
| - SECURITY_ATTRIBUTES security_attributes = {0};
|
| - security_attributes.nLength = sizeof(security_attributes);
|
| - security_attributes.lpSecurityDescriptor = nullptr;
|
| - security_attributes.bInheritHandle = TRUE;
|
| -
|
| - // Create the client end of the channel. This code should match the code in
|
| - // IPC::Channel.
|
| - base::File client(CreateFile(base::UTF8ToUTF16(pipe_name).c_str(),
|
| - GENERIC_READ | GENERIC_WRITE,
|
| - 0,
|
| - &security_attributes,
|
| - OPEN_EXISTING,
|
| - SECURITY_SQOS_PRESENT | SECURITY_IDENTIFICATION |
|
| - FILE_FLAG_OVERLAPPED,
|
| - nullptr));
|
| - if (!client.IsValid()) {
|
| - PLOG(ERROR) << "Failed to connect to '" << pipe_name << "'";
|
| - return false;
|
| - }
|
| -
|
| - *client_out = std::move(client);
|
| - *server_out = std::move(server);
|
| - return true;
|
| -}
|
| -
|
| bool CreateIpcChannel(
|
| const std::string& channel_name,
|
| const std::string& pipe_security_descriptor,
|
|
|