Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Unified Diff: remoting/host/remoting_me2me_host.cc

Issue 1838313002: Restart the host when the third party auth certificate changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewed Feedback from sergeyu@ Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/host/remoting_me2me_host.cc
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index 2460328157713065969fef344a444be07d218ae1..0f0beb8e00ec1561f0e78c6f3bf1badfc4db1a94 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -115,6 +115,7 @@
#undef Status // Xlib.h #defines this, which breaks protobuf headers.
#include <base/linux_util.h>
#include "remoting/host/audio_capturer_linux.h"
+#include "remoting/host/linux/certificate_watcher.h"
#endif // defined(OS_LINUX)
#if defined(OS_WIN)
@@ -366,6 +367,8 @@ class HostProcess : public ConfigWatcher::Delegate,
// Error handler for SignalingConnector.
void OnAuthFailed();
+ void OnHostRestartRequested();
+
void RestartHost(const std::string& host_offline_reason);
void ShutdownHost(HostExitCodes exit_code);
@@ -390,6 +393,11 @@ class HostProcess : public ConfigWatcher::Delegate,
scoped_ptr<ChromotingHostContext> context_;
+#if defined(OS_LINUX)
+ // Watch for certificate changes and kill the host when changes occur
+ scoped_ptr<CertificateWatcher> cert_watcher_;
+#endif
+
// XMPP server/remoting bot configuration (initialized from the command line).
XmppSignalStrategy::XmppServerConfig xmpp_server_config_;
std::string directory_bot_jid_;
@@ -807,6 +815,15 @@ void HostProcess::CreateAuthenticatorFactory() {
DCHECK(third_party_auth_config_.token_url.is_valid());
DCHECK(third_party_auth_config_.token_validation_url.is_valid());
+#if defined(OS_LINUX)
+ cert_watcher_.reset(new CertificateWatcher(
Sergey Ulanov 2016/03/31 22:36:16 CreateAuthenticatorFactory() is called every time
Yuwei 2016/03/31 23:08:33 Currently the watcher get constructed just before
Sergey Ulanov 2016/04/01 17:49:23 This code also resets it every time the host is re
Yuwei 2016/04/01 18:28:04 Okay. I guess I had mixed up the concept of HostPr
Yuwei 2016/04/01 23:41:03 Done.
+ host_->AsWeakPtr(),
+ base::Bind(&HostProcess::OnHostRestartRequested, this)));
+ context_->file_task_runner()->PostTask(
Sergey Ulanov 2016/03/31 22:36:16 I don't think you need to use file_task_runner() h
Yuwei 2016/03/31 23:08:33 I tried this but it complained something like it's
Sergey Ulanov 2016/04/01 17:49:23 Network thread is an IO thread (see https://code.g
Yuwei 2016/04/01 18:28:04 Interesting... I tried context_->network_task
Yuwei 2016/04/01 18:44:34 Line 114: network_task_runner->PostTask(FROM_HERE,
Sergey Ulanov 2016/04/01 20:11:00 I see. This error message is somewhat wrong. Netwo
Yuwei 2016/04/01 20:53:22 That sounds like a problem... I think I can start
+ FROM_HERE, base::Bind(&CertificateWatcher::Start,
+ base::Unretained(cert_watcher_.get())));
+#endif
+
scoped_refptr<protocol::TokenValidatorFactory> token_validator_factory =
new TokenValidatorFactoryImpl(third_party_auth_config_, key_pair_,
context_->url_request_context_getter());
@@ -1705,6 +1722,16 @@ void HostProcess::OnCrash(const std::string& function_name,
CHECK(false) << message;
}
+void HostProcess::OnHostRestartRequested() {
+ // restarts(shutdowns) the server when the certificate is updated
+ if (!context_->network_task_runner()->BelongsToCurrentThread()) {
+ context_->network_task_runner()->PostTask(FROM_HERE,
+ base::Bind(&HostProcess::OnHostRestartRequested, this));
+ return;
+ }
+ ShutdownHost(kSuccessExitCode);
+}
+
int HostProcessMain() {
HOST_LOG << "Starting host process: version " << STRINGIZE(VERSION);

Powered by Google App Engine
This is Rietveld 408576698