summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-01 18:55:35 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-01 18:55:35 +0000
commit5405bacef906d6539d2e267fdd1ce796a88d8b6c (patch)
treee235b586c21bf68a34e17622f5bb905a255dbe89 /remoting
parent437eff7e79871ebaa8a791d2fd9574615318c5ed (diff)
downloadchromium_src-5405bacef906d6539d2e267fdd1ce796a88d8b6c.zip
chromium_src-5405bacef906d6539d2e267fdd1ce796a88d8b6c.tar.gz
chromium_src-5405bacef906d6539d2e267fdd1ce796a88d8b6c.tar.bz2
Remove the need to have separate config for authentication.
Previously host was opening two separate configs, but that doesn't seem to be very useful. With that change the host still supports --auth-config option, but it no longer requires auth config and doesn't try to open auth.json by default. Review URL: https://chromiumcodereview.appspot.com/10825121 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149453 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/composite_host_config.cc46
-rw-r--r--remoting/host/composite_host_config.h43
-rw-r--r--remoting/host/installer/chromoting.wxs2
-rwxr-xr-xremoting/host/installer/mac/PrivilegedHelperTools/org.chromium.chromoting.me2me.sh2
-rw-r--r--remoting/host/remoting_me2me_host.cc77
-rw-r--r--remoting/remoting.gyp6
-rwxr-xr-xremoting/tools/me2me_virtual_host.py28
7 files changed, 144 insertions, 60 deletions
diff --git a/remoting/host/composite_host_config.cc b/remoting/host/composite_host_config.cc
new file mode 100644
index 0000000..cf130a9
--- /dev/null
+++ b/remoting/host/composite_host_config.cc
@@ -0,0 +1,46 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/composite_host_config.h"
+
+#include "remoting/host/json_host_config.h"
+
+namespace remoting {
+
+CompositeHostConfig::CompositeHostConfig() {
+}
+
+CompositeHostConfig::~CompositeHostConfig() {
+}
+
+bool CompositeHostConfig::AddConfigPath(const FilePath& path) {
+ scoped_ptr<JsonHostConfig> config(new JsonHostConfig(path));
+ if (!config->Read()) {
+ return false;
+ }
+ configs_.push_back(config.release());
+ return true;
+}
+
+bool CompositeHostConfig::GetString(const std::string& path,
+ std::string* out_value) const {
+ for (std::vector<HostConfig*>::const_iterator it = configs_.begin();
+ it != configs_.end(); ++it) {
+ if ((*it)->GetString(path, out_value))
+ return true;
+ }
+ return false;
+}
+
+bool CompositeHostConfig::GetBoolean(const std::string& path,
+ bool* out_value) const {
+ for (std::vector<HostConfig*>::const_iterator it = configs_.begin();
+ it != configs_.end(); ++it) {
+ if ((*it)->GetBoolean(path, out_value))
+ return true;
+ }
+ return false;
+}
+
+} // namespace remoting
diff --git a/remoting/host/composite_host_config.h b/remoting/host/composite_host_config.h
new file mode 100644
index 0000000..46b90b4
--- /dev/null
+++ b/remoting/host/composite_host_config.h
@@ -0,0 +1,43 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_HOST_COMPOSITE_HOST_CONFIG_H_
+#define REMOTING_HOST_COMPOSITE_HOST_CONFIG_H_
+
+#include "remoting/host/host_config.h"
+
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_vector.h"
+
+class FilePath;
+
+namespace remoting {
+
+// CompositeConfig reads multiple configuration files and merges them together.
+class CompositeHostConfig : public HostConfig {
+ public:
+ CompositeHostConfig();
+ virtual ~CompositeHostConfig();
+
+ // Add configuration file specified stored at |path|. Returns false if the
+ // file with the specified name doesn't exist or can't be opened. When the
+ // same parameter is present in more than one file priority is given to those
+ // that are added first.
+ bool AddConfigPath(const FilePath& path);
+
+ // HostConfig interface.
+ virtual bool GetString(const std::string& path,
+ std::string* out_value) const OVERRIDE;
+ virtual bool GetBoolean(const std::string& path,
+ bool* out_value) const OVERRIDE;
+
+ private:
+ ScopedVector<HostConfig> configs_;
+
+ DISALLOW_COPY_AND_ASSIGN(CompositeHostConfig);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_HOST_COMPOSITE_HOST_CONFIG_H_
diff --git a/remoting/host/installer/chromoting.wxs b/remoting/host/installer/chromoting.wxs
index a31c868..2f5d811 100644
--- a/remoting/host/installer/chromoting.wxs
+++ b/remoting/host/installer/chromoting.wxs
@@ -133,7 +133,7 @@
Name="$(var.ServiceName)"
DisplayName="[chromoting_service_display_name]"
Description="[chromoting_service_description]"
- Arguments="--auth-config=&quot;[config_files]host.json&quot; --host-config=&quot;[config_files]host.json&quot;"
+ Arguments="--host-config=&quot;[config_files]host.json&quot;"
Start="demand"
Account="LocalSystem"
ErrorControl="ignore"
diff --git a/remoting/host/installer/mac/PrivilegedHelperTools/org.chromium.chromoting.me2me.sh b/remoting/host/installer/mac/PrivilegedHelperTools/org.chromium.chromoting.me2me.sh
index f4b5a78..b2ed7ec 100755
--- a/remoting/host/installer/mac/PrivilegedHelperTools/org.chromium.chromoting.me2me.sh
+++ b/remoting/host/installer/mac/PrivilegedHelperTools/org.chromium.chromoting.me2me.sh
@@ -45,7 +45,7 @@ run_host() {
fi
# Execute the host asynchronously
- "$HOST_EXE" --auth-config="$CONFIG_FILE" --host-config="$CONFIG_FILE" &
+ "$HOST_EXE" --host-config="$CONFIG_FILE" &
HOST_PID="$!"
# Wait for the host to return and process its exit code.
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index 15b7907..e4aacab 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -28,23 +28,23 @@
#include "remoting/base/breakpad.h"
#include "remoting/base/constants.h"
#include "remoting/host/branding.h"
-#include "remoting/host/constants.h"
-#include "remoting/host/video_frame_capturer.h"
#include "remoting/host/chromoting_host.h"
#include "remoting/host/chromoting_host_context.h"
+#include "remoting/host/composite_host_config.h"
+#include "remoting/host/constants.h"
#include "remoting/host/desktop_environment.h"
#include "remoting/host/event_executor.h"
#include "remoting/host/heartbeat_sender.h"
#include "remoting/host/host_config.h"
#include "remoting/host/host_event_logger.h"
#include "remoting/host/host_user_interface.h"
-#include "remoting/host/json_host_config.h"
#include "remoting/host/log_to_server.h"
#include "remoting/host/network_settings.h"
#include "remoting/host/policy_hack/policy_watcher.h"
#include "remoting/host/session_manager_factory.h"
#include "remoting/host/signaling_connector.h"
#include "remoting/host/usage_stats_consent.h"
+#include "remoting/host/video_frame_capturer.h"
#include "remoting/jingle_glue/xmpp_signal_strategy.h"
#include "remoting/protocol/me2me_host_authenticator_factory.h"
@@ -70,8 +70,6 @@ const char kApplicationName[] = "chromoting";
const char kAuthConfigSwitchName[] = "auth-config";
const char kHostConfigSwitchName[] = "host-config";
-const FilePath::CharType kDefaultAuthConfigFile[] =
- FILE_PATH_LITERAL("auth.json");
const FilePath::CharType kDefaultHostConfigFile[] =
FILE_PATH_LITERAL("host.json");
@@ -113,23 +111,24 @@ class HostProcess
&HostProcess::ConfigUpdatedDelayed));
}
- void InitWithCommandLine(const CommandLine* cmd_line) {
+ bool InitWithCommandLine(const CommandLine* cmd_line) {
FilePath default_config_dir = remoting::GetConfigDir();
if (cmd_line->HasSwitch(kAuthConfigSwitchName)) {
- auth_config_path_ = cmd_line->GetSwitchValuePath(kAuthConfigSwitchName);
- } else {
- auth_config_path_ = default_config_dir.Append(kDefaultAuthConfigFile);
+ FilePath path = cmd_line->GetSwitchValuePath(kAuthConfigSwitchName);
+ if (!config_.AddConfigPath(path)) {
+ return false;
+ }
}
+ host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile);
if (cmd_line->HasSwitch(kHostConfigSwitchName)) {
host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName);
- } else {
- host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile);
+ }
+ if (!config_.AddConfigPath(host_config_path_)) {
+ return false;
}
-#if defined(OS_LINUX)
- VideoFrameCapturer::EnableXDamage(true);
-#endif
+ return true;
}
void ConfigUpdated() {
@@ -249,34 +248,20 @@ class HostProcess
base::Bind(&HostProcess::OnPolicyUpdate, base::Unretained(this)));
}
- // Read Host config from disk, returning true if successful.
+ // Read host config, returning true if successful.
bool LoadConfig() {
- JsonHostConfig host_config(host_config_path_);
- JsonHostConfig auth_config(auth_config_path_);
-
- FilePath failed_path;
- if (!host_config.Read()) {
- failed_path = host_config_path_;
- } else if (!auth_config.Read()) {
- failed_path = auth_config_path_;
- }
- if (!failed_path.empty()) {
- LOG(ERROR) << "Failed to read configuration file " << failed_path.value();
- return false;
- }
-
- if (!host_config.GetString(kHostIdConfigPath, &host_id_)) {
+ if (!config_.GetString(kHostIdConfigPath, &host_id_)) {
LOG(ERROR) << "host_id is not defined in the config.";
return false;
}
- if (!key_pair_.Load(host_config)) {
+ if (!key_pair_.Load(config_)) {
return false;
}
std::string host_secret_hash_string;
- if (!host_config.GetString(kHostSecretHashConfigPath,
- &host_secret_hash_string)) {
+ if (!config_.GetString(kHostSecretHashConfigPath,
+ &host_secret_hash_string)) {
host_secret_hash_string = "plain:";
}
@@ -286,10 +271,10 @@ class HostProcess
}
// Use an XMPP connection to the Talk network for session signalling.
- if (!auth_config.GetString(kXmppLoginConfigPath, &xmpp_login_) ||
- !(auth_config.GetString(kXmppAuthTokenConfigPath, &xmpp_auth_token_) ||
- auth_config.GetString(kOAuthRefreshTokenConfigPath,
- &oauth_refresh_token_))) {
+ if (!config_.GetString(kXmppLoginConfigPath, &xmpp_login_) ||
+ !(config_.GetString(kXmppAuthTokenConfigPath, &xmpp_auth_token_) ||
+ config_.GetString(kOAuthRefreshTokenConfigPath,
+ &oauth_refresh_token_))) {
LOG(ERROR) << "XMPP credentials are not defined in the config.";
return false;
}
@@ -298,14 +283,14 @@ class HostProcess
// depending on whether this is an official build or not.
// If the client-Id type to use is not specified we default based on
// the build type.
- auth_config.GetBoolean(kOAuthUseOfficialClientIdConfigPath,
- &oauth_use_official_client_id_);
+ config_.GetBoolean(kOAuthUseOfficialClientIdConfigPath,
+ &oauth_use_official_client_id_);
if (!oauth_refresh_token_.empty()) {
xmpp_auth_token_ = ""; // This will be set to the access token later.
xmpp_auth_service_ = "oauth2";
- } else if (!auth_config.GetString(kXmppAuthServiceConfigPath,
- &xmpp_auth_service_)) {
+ } else if (!config_.GetString(kXmppAuthServiceConfigPath,
+ &xmpp_auth_service_)) {
// For the me2me host, we default to ClientLogin token for chromiumsync
// because earlier versions of the host had no HTTP stack with which to
// request an OAuth2 access token.
@@ -501,8 +486,8 @@ class HostProcess
scoped_ptr<ChromotingHostContext> context_;
scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
- FilePath auth_config_path_;
FilePath host_config_path_;
+ CompositeHostConfig config_;
std::string host_id_;
HostKeyPair key_pair_;
@@ -579,8 +564,14 @@ int main(int argc, char** argv) {
// single-threaded.
net::EnableSSLServerSockets();
+#if defined(OS_LINUX)
+ remoting::VideoFrameCapturer::EnableXDamage(true);
+#endif
+
remoting::HostProcess me2me_host;
- me2me_host.InitWithCommandLine(cmd_line);
+ if (!me2me_host.InitWithCommandLine(cmd_line)) {
+ return remoting::kInvalidHostConfigurationExitCode;
+ }
return me2me_host.Run();
}
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index df6ab09..d44361b 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -1220,6 +1220,8 @@
'host/clipboard_linux.cc',
'host/clipboard_mac.mm',
'host/clipboard_win.cc',
+ 'host/composite_host_config.cc',
+ 'host/composite_host_config.h',
'host/constants.h',
'host/constants_mac.cc',
'host/constants_mac.h',
@@ -1241,10 +1243,10 @@
'host/event_executor_linux.cc',
'host/event_executor_mac.cc',
'host/event_executor_win.cc',
- 'host/heartbeat_sender.cc',
- 'host/heartbeat_sender.h',
'host/gaia_oauth_client.cc',
'host/gaia_oauth_client.h',
+ 'host/heartbeat_sender.cc',
+ 'host/heartbeat_sender.h',
'host/host_config.cc',
'host/host_config.h',
'host/host_key_pair.cc',
diff --git a/remoting/tools/me2me_virtual_host.py b/remoting/tools/me2me_virtual_host.py
index 21eebb6..95ee7b7 100755
--- a/remoting/tools/me2me_virtual_host.py
+++ b/remoting/tools/me2me_virtual_host.py
@@ -44,9 +44,6 @@ XSESSION_COMMAND = None
REMOTING_COMMAND = "remoting_me2me_host"
-# Command-line switch for passing the config path to remoting_me2me_host.
-HOST_CONFIG_SWITCH_NAME = "host-config"
-
# Needs to be an absolute path, since the current working directory is changed
# when this process self-daemonizes.
SCRIPT_PATH = os.path.dirname(sys.argv[0])
@@ -148,21 +145,24 @@ class Host:
server = 'www.googleapis.com'
url = 'https://' + server + '/chromoting/v1/@me/hosts'
- def __init__(self, config_file):
+ def __init__(self, config_file, auth):
+ """
+ Args:
+ config_file: Host configuration file path
+ auth: Authentication object with credentials for authenticating with the
+ Directory service.
+ """
self.config_file = config_file
+ self.auth = auth
self.host_id = str(uuid.uuid1())
self.host_name = socket.gethostname()
self.host_secret_hash = None
self.private_key = None
- def register(self, auth):
+ def register(self):
"""Generates a private key for the stored |host_id|, and registers it with
the Directory service.
- Args:
- auth: Authentication object with credentials for authenticating with the
- Directory service.
-
Raises:
urllib2.HTTPError: An error occurred talking to the Directory server
(for example, if the |auth| credentials were rejected).
@@ -184,7 +184,7 @@ class Host:
}
params = json.dumps(json_data)
headers = {
- "Authorization": "GoogleLogin auth=" + auth.chromoting_auth_token,
+ "Authorization": "GoogleLogin auth=" + self.auth.chromoting_auth_token,
"Content-Type": "application/json",
}
@@ -383,7 +383,8 @@ class Desktop:
def launch_host(self, host):
# Start remoting host
args = [locate_executable(REMOTING_COMMAND),
- "--%s=%s" % (HOST_CONFIG_SWITCH_NAME, host.config_file)]
+ "--host_config=%s" % (host.config_file),
+ "--auth_config=%s" % (host.auth.config_file)]
self.host_proc = subprocess.Popen(args, env=self.child_env)
if not self.host_proc.pid:
raise Exception("Could not start remoting host")
@@ -692,10 +693,11 @@ def main():
settings_file.write(options.explicit_config)
settings_file.close()
+ # TODO(sergeyu): Move auth parameters to the host config.
auth = Authentication(os.path.join(CONFIG_DIR, "auth.json"))
need_auth_tokens = not auth.load_config()
- host = Host(os.path.join(CONFIG_DIR, "host#%s.json" % host_hash))
+ host = Host(os.path.join(CONFIG_DIR, "host#%s.json" % host_hash), auth)
register_host = not host.load_config()
# Outside the loop so user doesn't get asked twice.
@@ -726,7 +728,7 @@ def main():
try:
if register_host:
- host.register(auth)
+ host.register()
host.save_config()
except urllib2.HTTPError, err:
if err.getcode() == 401: