summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorweitaosu@chromium.org <weitaosu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-13 21:47:39 +0000
committerweitaosu@chromium.org <weitaosu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-13 21:47:39 +0000
commitb301e8f6f8db1cdf203a705ac8effcd9b56117af (patch)
treea00498289ebffd487c14e2551c3054c16d0993c2 /remoting
parente3c307972900d802c2bb4b68d2d2f29fc21e94f2 (diff)
downloadchromium_src-b301e8f6f8db1cdf203a705ac8effcd9b56117af.zip
chromium_src-b301e8f6f8db1cdf203a705ac8effcd9b56117af.tar.gz
chromium_src-b301e8f6f8db1cdf203a705ac8effcd9b56117af.tar.bz2
Enable pairing registry in me2me native messaging host on Windows:
1. Build a standalone remoting_native_messaging_host.exe. remoting_host.exe is a win32 application (as opposed to console application) thus not suitable as a native messaging host. 2. Initialize the pairing registry reg keys in the native messaging host. 3. GetPairdClients doesn't require elevation. 4. Add the native messaging host binary and manifest and the pairing reg keys to the installer. Enable pairing registry in Me2Me native messaging host on Windows. BUG=325567 Review URL: https://codereview.chromium.org/143303007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251137 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/daemon_process_win.cc22
-rw-r--r--remoting/host/installer/win/chromoting.wxs44
-rw-r--r--remoting/host/pairing_registry_delegate_win.h11
-rw-r--r--remoting/host/setup/me2me_native_messaging_host.cc5
-rw-r--r--remoting/host/setup/me2me_native_messaging_host_main.cc55
-rw-r--r--remoting/remoting_host.gypi46
-rw-r--r--remoting/remoting_host_win.gypi3
7 files changed, 137 insertions, 49 deletions
diff --git a/remoting/host/daemon_process_win.cc b/remoting/host/daemon_process_win.cc
index fa91cb6..a03140d 100644
--- a/remoting/host/daemon_process_win.cc
+++ b/remoting/host/daemon_process_win.cc
@@ -28,6 +28,7 @@
#include "remoting/host/host_exit_codes.h"
#include "remoting/host/host_main.h"
#include "remoting/host/ipc_constants.h"
+#include "remoting/host/pairing_registry_delegate_win.h"
#include "remoting/host/screen_resolution.h"
#include "remoting/host/win/launch_process_with_token.h"
#include "remoting/host/win/unprivileged_process_delegate.h"
@@ -38,17 +39,6 @@ using base::TimeDelta;
namespace {
-#if defined(OFFICIAL_BUILD)
-const wchar_t kPairingRegistryKeyName[] =
- L"SOFTWARE\\Google\\Chrome Remote Desktop\\paired-clients";
-#else
-const wchar_t kPairingRegistryKeyName[] =
- L"SOFTWARE\\Chromoting\\paired-clients";
-#endif
-
-const wchar_t kPrivilegedKeyName[] = L"secrets";
-const wchar_t kUnprivilegedKeyName[] = L"clients";
-
// Duplicates |key| into |target_process| and returns the value that can be sent
// over IPC.
IPC::PlatformFileForTransit GetRegistryKeyForTransit(
@@ -318,22 +308,22 @@ bool DaemonProcessWin::OpenPairingRegistry() {
}
base::win::RegKey privileged;
- result = privileged.Open(root.Handle(), kPrivilegedKeyName,
+ result = privileged.Open(root.Handle(), kPairingRegistryClientsKeyName,
KEY_READ | KEY_WRITE);
if (result != ERROR_SUCCESS) {
SetLastError(result);
PLOG(ERROR) << "Failed to open HKLM\\" << kPairingRegistryKeyName << "\\"
- << kPrivilegedKeyName;
+ << kPairingRegistryClientsKeyName;
return false;
}
base::win::RegKey unprivileged;
- result = unprivileged.Open(root.Handle(), kUnprivilegedKeyName,
+ result = unprivileged.Open(root.Handle(), kPairingRegistrySecretsKeyName,
KEY_READ | KEY_WRITE);
if (result != ERROR_SUCCESS) {
SetLastError(result);
- PLOG(ERROR) << "Failed to open HKLM\\" << kUnprivilegedKeyName << "\\"
- << kUnprivilegedKeyName;
+ PLOG(ERROR) << "Failed to open HKLM\\" << kPairingRegistrySecretsKeyName
+ << "\\" << kPairingRegistrySecretsKeyName;
return false;
}
diff --git a/remoting/host/installer/win/chromoting.wxs b/remoting/host/installer/win/chromoting.wxs
index a1c8b83..3866df4 100644
--- a/remoting/host/installer/win/chromoting.wxs
+++ b/remoting/host/installer/win/chromoting.wxs
@@ -188,6 +188,22 @@
Vital="yes"/>
</Component>
+ <Component Id="remoting_native_messaging_host" Guid="*">
+ <File Id="remoting_native_messaging_host.exe"
+ DiskId="1"
+ KeyPath="yes"
+ Name="remoting_native_messaging_host.exe"
+ Vital="yes"/>
+ </Component>
+
+ <Component Id="native_messaging_host_manifest" Guid="*">
+ <File Id="com.google.chrome.remote_desktop.json"
+ DiskId="1"
+ KeyPath="yes"
+ Name="com.google.chrome.remote_desktop.json"
+ Vital="yes"/>
+ </Component>
+
<Component Id="icudtl" Guid="*">
<File Id="icudtl.dat"
DiskId="1"
@@ -492,9 +508,28 @@
Windows Installer version 4.5 or lower. Also Cannot use
PermissionEx in WixUtilExtension because it automatically
inherits all the ACLs from the parent. -->
- <Permission User="SYSTEM" GenericAll="yes"
- ChangePermission="yes"
- TakeOwnership="yes"/>
+ <Permission User="SYSTEM"
+ GenericAll="yes"
+ ChangePermission="yes"
+ TakeOwnership="yes"/>
+ <Permission User="Administrators"
+ Domain="[LOCAL_MACHINE_NAME]"
+ GenericAll="yes"
+ ChangePermission="yes"
+ TakeOwnership="yes"/>
+ </RegistryKey>
+ </RegistryKey>
+ <CreateFolder/>
+ </Component>
+
+ <Component Id="native_messaging_host_registry" Guid="*">
+ <RegistryKey Root="HKLM"
+ Key="SOFTWARE\Google\chrome\NativeMessagingHosts"
+ Action="create">
+ <RegistryKey Key="com.google.chrome.remote_desktop" Action="create">
+ <RegistryValue
+ Type="string"
+ Value="[binaries]com.google.chrome.remote_desktop.json"/>
</RegistryKey>
</RegistryKey>
<CreateFolder/>
@@ -600,6 +635,9 @@
<ComponentRef Id="omaha_registration"/>
<?endif?>
<ComponentRef Id="icudtl"/>
+ <ComponentRef Id="remoting_native_messaging_host"/>
+ <ComponentRef Id="native_messaging_host_manifest"/>
+ <ComponentRef Id="native_messaging_host_registry"/>
<ComponentRef Id="remoting_core"/>
<ComponentRef Id="remoting_desktop"/>
<ComponentRef Id="remoting_host"/>
diff --git a/remoting/host/pairing_registry_delegate_win.h b/remoting/host/pairing_registry_delegate_win.h
index ecbd4a2..93ce5cb 100644
--- a/remoting/host/pairing_registry_delegate_win.h
+++ b/remoting/host/pairing_registry_delegate_win.h
@@ -19,6 +19,17 @@ class ListValue;
namespace remoting {
+#if defined(OFFICIAL_BUILD)
+const wchar_t kPairingRegistryKeyName[] =
+ L"SOFTWARE\\Google\\Chrome Remote Desktop\\paired-clients";
+#else
+const wchar_t kPairingRegistryKeyName[] =
+ L"SOFTWARE\\Chromoting\\paired-clients";
+#endif
+
+const wchar_t kPairingRegistryClientsKeyName[] = L"secrets";
+const wchar_t kPairingRegistrySecretsKeyName[] = L"clients";
+
// Stores client pairing information in Windows registry. Two separate registry
// keys are used:
// - |privileged| - contains the shared secrets of all pairings. This key must
diff --git a/remoting/host/setup/me2me_native_messaging_host.cc b/remoting/host/setup/me2me_native_messaging_host.cc
index ce8686f..1c56f63 100644
--- a/remoting/host/setup/me2me_native_messaging_host.cc
+++ b/remoting/host/setup/me2me_native_messaging_host.cc
@@ -289,11 +289,6 @@ void Me2MeNativeMessagingHost::ProcessGetPairedClients(
scoped_ptr<base::DictionaryValue> response) {
DCHECK(thread_checker_.CalledOnValidThread());
- if (needs_elevation_) {
- DelegateToElevatedHost(message.Pass(), response.Pass());
- return;
- }
-
if (pairing_registry_) {
pairing_registry_->GetAllPairings(
base::Bind(&Me2MeNativeMessagingHost::SendPairedClientsResponse,
diff --git a/remoting/host/setup/me2me_native_messaging_host_main.cc b/remoting/host/setup/me2me_native_messaging_host_main.cc
index 638b15b..ac929b8 100644
--- a/remoting/host/setup/me2me_native_messaging_host_main.cc
+++ b/remoting/host/setup/me2me_native_messaging_host_main.cc
@@ -14,9 +14,13 @@
#include "remoting/host/setup/me2me_native_messaging_host.h"
#if defined(OS_WIN)
+#include "base/win/registry.h"
#include "base/win/windows_version.h"
+#include "remoting/host/pairing_registry_delegate_win.h"
#endif // defined(OS_WIN)
+using remoting::protocol::PairingRegistry;
+
namespace {
const char kParentWindowSwitchName[] = "parent-window";
@@ -140,14 +144,61 @@ int Me2MeNativeMessagingHostMain() {
net::URLFetcher::SetIgnoreCertificateRequests(true);
- // Create the pairing registry and native messaging host.
- scoped_refptr<protocol::PairingRegistry> pairing_registry =
+ // Create the pairing registry.
+ scoped_refptr<PairingRegistry> pairing_registry;
+
+#if defined(OS_WIN)
+ base::win::RegKey root;
+ LONG result = root.Open(HKEY_LOCAL_MACHINE, kPairingRegistryKeyName,
+ KEY_READ);
+ if (result != ERROR_SUCCESS) {
+ SetLastError(result);
+ PLOG(ERROR) << "Failed to open HKLM\\" << kPairingRegistryKeyName;
+ return kInitializationFailed;
+ }
+
+ base::win::RegKey unprivileged;
+ result = unprivileged.Open(root.Handle(), kPairingRegistrySecretsKeyName,
+ needs_elevation ? KEY_READ : KEY_READ | KEY_WRITE);
+ if (result != ERROR_SUCCESS) {
+ SetLastError(result);
+ PLOG(ERROR) << "Failed to open HKLM\\" << kPairingRegistrySecretsKeyName
+ << "\\" << kPairingRegistrySecretsKeyName;
+ return kInitializationFailed;
+ }
+
+ // Only try to open the privileged key if the current process is elevated.
+ base::win::RegKey privileged;
+ if (!needs_elevation) {
+ result = privileged.Open(root.Handle(), kPairingRegistryClientsKeyName,
+ KEY_READ | KEY_WRITE);
+ if (result != ERROR_SUCCESS) {
+ SetLastError(result);
+ PLOG(ERROR) << "Failed to open HKLM\\" << kPairingRegistryKeyName << "\\"
+ << kPairingRegistryClientsKeyName;
+ return kInitializationFailed;
+ }
+ }
+
+ // Initialize the pairing registry delegate and set the root keys.
+ scoped_ptr<PairingRegistryDelegateWin> delegate(
+ new PairingRegistryDelegateWin());
+ if (!delegate->SetRootKeys(privileged.Take(), unprivileged.Take()))
+ return kInitializationFailed;
+
+ pairing_registry = new PairingRegistry(
+ io_thread.message_loop_proxy(),
+ delegate.PassAs<PairingRegistry::Delegate>());
+#else // defined(OS_WIN)
+ pairing_registry =
CreatePairingRegistry(io_thread.message_loop_proxy());
+#endif // !defined(OS_WIN)
// Set up the native messaging channel.
scoped_ptr<NativeMessagingChannel> channel(
new NativeMessagingChannel(read_file, write_file));
+ // Create the native messaging host.
scoped_ptr<Me2MeNativeMessagingHost> host(
new Me2MeNativeMessagingHost(
needs_elevation,
diff --git a/remoting/remoting_host.gypi b/remoting/remoting_host.gypi
index 1b80c36..161d68a 100644
--- a/remoting/remoting_host.gypi
+++ b/remoting/remoting_host.gypi
@@ -557,6 +557,28 @@
],
}, # end of target 'remoting_it2me_host_static'
{
+ 'target_name': 'remoting_me2me_native_messaging_host',
+ 'type': 'executable',
+ 'product_name': 'remoting_native_messaging_host',
+ 'variables': { 'enable_wexit_time_destructors': 1, },
+ 'dependencies': [
+ '../base/base.gyp:base',
+ 'remoting_host',
+ 'remoting_host_setup_base',
+ 'remoting_native_messaging_base',
+ ],
+ 'sources': [
+ 'host/setup/me2me_native_messaging_host_main.cc',
+ ],
+ 'conditions': [
+ ['OS=="linux" and linux_use_tcmalloc==1', {
+ 'dependencies': [
+ '../base/allocator/allocator.gyp:allocator',
+ ],
+ }],
+ ],
+ }, # end of target 'remoting_me2me_native_messaging_host'
+ {
'target_name': 'remoting_it2me_native_messaging_host',
'type': 'executable',
'variables': { 'enable_wexit_time_destructors': 1, },
@@ -610,7 +632,7 @@
'conditions': [
[ 'OS == "win"', {
'variables': {
- 'me2me_host_path': 'remoting_host.exe',
+ 'me2me_host_path': 'remoting_native_messaging_host.exe',
'it2me_host_path': 'remoting_assistance_host.exe',
},
}],
@@ -789,28 +811,6 @@
}], # OS=linux
], # end of 'conditions'
}, # end of target 'remoting_me2me_host'
- {
- 'target_name': 'remoting_me2me_native_messaging_host',
- 'type': 'executable',
- 'product_name': 'remoting_native_messaging_host',
- 'variables': { 'enable_wexit_time_destructors': 1, },
- 'dependencies': [
- '../base/base.gyp:base',
- 'remoting_host',
- 'remoting_host_setup_base',
- 'remoting_native_messaging_base',
- ],
- 'sources': [
- 'host/setup/me2me_native_messaging_host_main.cc',
- ],
- 'conditions': [
- ['OS=="linux" and linux_use_tcmalloc==1', {
- 'dependencies': [
- '../base/allocator/allocator.gyp:allocator',
- ],
- }],
- ],
- }, # end of target 'remoting_me2me_native_messaging_host'
], # end of 'targets'
}], # OS!="win"
diff --git a/remoting/remoting_host_win.gypi b/remoting/remoting_host_win.gypi
index 87b64a6..4e24861 100644
--- a/remoting/remoting_host_win.gypi
+++ b/remoting/remoting_host_win.gypi
@@ -465,17 +465,20 @@
'remoting_core',
'remoting_desktop',
'remoting_host_exe',
+ 'remoting_me2me_native_messaging_host',
'remoting_native_messaging_manifests',
],
'compiled_inputs': [
'<(PRODUCT_DIR)/remoting_core.dll',
'<(PRODUCT_DIR)/remoting_desktop.exe',
'<(PRODUCT_DIR)/remoting_host.exe',
+ '<(PRODUCT_DIR)/remoting_native_messaging_host.exe',
],
'compiled_inputs_dst': [
'files/remoting_core.dll',
'files/remoting_desktop.exe',
'files/remoting_host.exe',
+ 'files/remoting_native_messaging_host.exe',
],
'conditions': [
['buildtype == "Official"', {