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

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: 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 eac1eec54792476712f96409c0062e1e17299a34..f87a0e47cdf3c05fbe5fa29463752a9dd6568f57 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -114,6 +114,8 @@
#include <X11/Xlib.h>
#include <base/linux_util.h>
#include "remoting/host/audio_capturer_linux.h"
+#include "remoting/host/linux/certificate_watcher.h"
+#include "remoting/host/linux/certificate_watcher_inhibitor.h"
#endif // defined(OS_LINUX)
#if defined(OS_WIN)
@@ -178,6 +180,10 @@ const int kShutdownTimeoutSeconds = 15;
// before continuing normal process shutdown.
const int kHostOfflineReasonTimeoutSeconds = 10;
+// Delay time to shutdown the host when a change of NSS database is detected.
+// This is to repeating restarts when continuous writes to the database occur.
+const int kCertUpdateShutdownDelaySeconds = 30;
Sergey Ulanov 2016/03/29 19:40:05 I don't think we need delay restart that long. Cur
Yuwei 2016/03/29 19:57:03 Acknowledged.
Sergey Ulanov 2016/03/29 23:09:54 Normally we use "Acknowledged." response only for
Yuwei 2016/03/30 18:47:45 Done. DelayedTimer is being used.
+
// Host offline reasons not associated with shutting down the host process
// and therefore not expressible through HostExitCodes enum.
const char kHostOfflineReasonPolicyReadError[] = "POLICY_READ_ERROR";
@@ -269,6 +275,7 @@ class HostProcess : public ConfigWatcher::Delegate,
IPC::PlatformFileForTransit unprivileged_key);
private:
+
// See SetState method for a list of allowed state transitions.
enum HostState {
// Waiting for valid config and policies to be read from the disk.
@@ -389,6 +396,12 @@ class HostProcess : public ConfigWatcher::Delegate,
scoped_ptr<ChromotingHostContext> context_;
+#if defined(OS_LINUX)
+ // Watch for NSS database changes and kill the host when changes occur
+ CertificateWatcher cert_watcher_;
+ CertificateWatcherInhibitor cert_watcher_inhibitor_;
+#endif
+
// XMPP server/remoting bot configuration (initialized from the command line).
XmppSignalStrategy::XmppServerConfig xmpp_server_config_;
std::string directory_bot_jid_;
@@ -482,6 +495,14 @@ HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context,
int* exit_code_out,
ShutdownWatchdog* shutdown_watchdog)
: context_(std::move(context)),
+#if defined(OS_LINUX)
+ cert_watcher_(context_->file_task_runner(),
+ context_->network_task_runner(),
+ kCertUpdateShutdownDelaySeconds,
+ base::Bind(&HostProcess::ShutdownHost,
+ this, kSuccessExitCode)),
+ cert_watcher_inhibitor_(cert_watcher_),
+#endif
state_(HOST_STARTING),
use_service_account_(false),
enable_vp9_(false),
@@ -806,6 +827,11 @@ 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_.Start();
+ host_->AddStatusObserver(&cert_watcher_inhibitor_);
Sergey Ulanov 2016/03/29 19:40:05 You also need to call RemoveStatusObserver() befor
Yuwei 2016/03/29 19:57:03 Acknowledged.
Yuwei 2016/03/29 21:37:41 I am a little bit confused... So the host will not
Sergey Ulanov 2016/03/29 23:09:54 In general when using the observer pattern it's ne
Yuwei 2016/03/30 18:47:45 Done. Observer will be added or removed in Start()
+#endif
+
scoped_refptr<protocol::TokenValidatorFactory> token_validator_factory =
new TokenValidatorFactoryImpl(third_party_auth_config_, key_pair_,
context_->url_request_context_getter());

Powered by Google App Engine
This is Rietveld 408576698