diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-03 00:59:50 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-03 00:59:50 +0000 |
commit | 44414bc38f386f549b9cddcb145f2f60f18f7a8a (patch) | |
tree | 1bc2e4aba05087b0cc1022c4e2a3c045eb8dbf74 /remoting | |
parent | 0bdfe5f9da1526a7bf47f8a919f239760646fef0 (diff) | |
download | chromium_src-44414bc38f386f549b9cddcb145f2f60f18f7a8a.zip chromium_src-44414bc38f386f549b9cddcb145f2f60f18f7a8a.tar.gz chromium_src-44414bc38f386f549b9cddcb145f2f60f18f7a8a.tar.bz2 |
Cleanup chromoting host config handling on Linux.
1. Host config was previously passed through stdin by specifying
--host-config=/dev/stdin . But the host process wasn't aware that the
config is read from stdin - it still watched /dev/stdin, which leads
to wrong behaviour when OS is upgraded (watch notification is fired
for /dev/stdin).
2. Previous the daemon script would erase content of the host config
when host exits with the error code indicating that the config is
invalid. There is no reason to do that anymore. Cleanup that code
so the config is erased only when the host is delete from the
directory (crbug.com/179416).
BUG=264910
R=lambroslambrou@chromium.org
Review URL: https://codereview.chromium.org/20776003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215436 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/remoting_me2me_host.cc | 42 | ||||
-rwxr-xr-x | remoting/tools/me2me_virtual_host.py | 27 |
2 files changed, 38 insertions, 31 deletions
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index fed6031..52b0fd3 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc @@ -110,6 +110,10 @@ const char kAudioPipeSwitchName[] = "audio-pipe-name"; // when it is successfully started. const char kSignalParentSwitchName[] = "signal-parent"; +// Value used for --host-config option to indicate that the path must be read +// from stdin. +const char kStdinConfigPath[] = "-"; + void QuitMessageLoop(base::MessageLoop* message_loop) { message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); } @@ -249,6 +253,7 @@ class HostProcess // Created on the UI thread but used from the network thread. base::FilePath host_config_path_; + std::string host_config_; scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; // Accessed on the network thread. @@ -366,10 +371,26 @@ bool HostProcess::InitWithCommandLine(const CommandLine* cmd_line) { context_->network_task_runner().get())); } - base::FilePath default_config_dir = remoting::GetConfigDir(); - host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile); if (cmd_line->HasSwitch(kHostConfigSwitchName)) { host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName); + + // Read config from stdin if necessary. + if (host_config_path_ == base::FilePath(kStdinConfigPath)) { + char buf[4096]; + size_t len; + while ((len = fread(buf, 1, sizeof(buf), stdin)) > 0) { + host_config_.append(buf, len); + } + } + } else { + base::FilePath default_config_dir = remoting::GetConfigDir(); + host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile); + } + + if (host_config_path_ != base::FilePath(kStdinConfigPath) && + !base::PathExists(host_config_path_)) { + LOG(ERROR) << "Can't find host config at " << host_config_path_.value(); + return false; } #endif // !defined(REMOTING_MULTI_PROCESS) @@ -449,11 +470,16 @@ void HostProcess::StartOnNetworkThread() { DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); #if !defined(REMOTING_MULTI_PROCESS) - // Start watching the host configuration file. - config_watcher_.reset(new ConfigFileWatcher(context_->network_task_runner(), - context_->file_task_runner(), - this)); - config_watcher_->Watch(host_config_path_); + if (host_config_path_ == base::FilePath(kStdinConfigPath)) { + // Process config we've read from stdin. + OnConfigUpdated(host_config_); + } else { + // Start watching the host configuration file. + config_watcher_.reset(new ConfigFileWatcher(context_->network_task_runner(), + context_->file_task_runner(), + this)); + config_watcher_->Watch(host_config_path_); + } #endif // !defined(REMOTING_MULTI_PROCESS) #if defined(OS_POSIX) @@ -568,7 +594,7 @@ void HostProcess::StartOnUiThread() { // Shutdown the host if the command line is invalid. context_->network_task_runner()->PostTask( FROM_HERE, base::Bind(&HostProcess::ShutdownHost, this, - kInvalidHostConfigurationExitCode)); + kUsageExitCode)); return; } diff --git a/remoting/tools/me2me_virtual_host.py b/remoting/tools/me2me_virtual_host.py index 117dc07..2118e4d 100755 --- a/remoting/tools/me2me_virtual_host.py +++ b/remoting/tools/me2me_virtual_host.py @@ -126,16 +126,8 @@ class Config: self.data[key] = value self.changed = True - def clear_auth(self): - del self.data["xmpp_login"] - del self.data["oauth_refresh_token"] - self.changed = True - - def clear_host_info(self): - del self.data["host_id"] - del self.data["host_name"] - del self.data["host_secret_hash"] - del self.data["private_key"] + def clear(self): + self.data = {} self.changed = True @@ -426,7 +418,7 @@ class Desktop: def launch_host(self, host_config): # Start remoting host - args = [locate_executable(HOST_BINARY_NAME), "--host-config=/dev/stdin"] + args = [locate_executable(HOST_BINARY_NAME), "--host-config=-"] if self.pulseaudio_pipe: args.append("--audio-pipe-name=%s" % self.pulseaudio_pipe) if self.server_supports_exact_resize: @@ -1133,32 +1125,21 @@ Web Store: https://chrome.google.com/remotedesktop""" if os.WIFEXITED(status): if os.WEXITSTATUS(status) == 100: logging.info("Host configuration is invalid - exiting.") - host_config.clear_auth() - host_config.clear_host_info() - host_config.save_and_log_errors() return 0 elif os.WEXITSTATUS(status) == 101: logging.info("Host ID has been deleted - exiting.") - host_config.clear_host_info() + host_config.clear() host_config.save_and_log_errors() return 0 elif os.WEXITSTATUS(status) == 102: logging.info("OAuth credentials are invalid - exiting.") - host_config.clear_auth() - host_config.save_and_log_errors() return 0 elif os.WEXITSTATUS(status) == 103: logging.info("Host domain is blocked by policy - exiting.") - host_config.clear_auth() - host_config.clear_host_info() - host_config.save_and_log_errors() return 0 # Nothing to do for Mac-only status 104 (login screen unsupported) elif os.WEXITSTATUS(status) == 105: logging.info("Username is blocked by policy - exiting.") - host_config.clear_auth() - host_config.clear_host_info() - host_config.save_and_log_errors() return 0 else: logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) |