summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remoting/host/remoting_me2me_host.cc42
-rwxr-xr-xremoting/tools/me2me_virtual_host.py27
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))