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

Side by Side Diff: remoting/host/remoting_me2me_host.cc

Issue 320123002: Fix token URL policy processing. Refactor/clean-up individual policy processing. Separate policy ap… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // This file implements a standalone host process for Me2Me. 5 // This file implements a standalone host process for Me2Me.
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 216
217 // Called on the network thread to set the host's Authenticator factory. 217 // Called on the network thread to set the host's Authenticator factory.
218 void CreateAuthenticatorFactory(); 218 void CreateAuthenticatorFactory();
219 219
220 // Tear down resources that run on the UI thread. 220 // Tear down resources that run on the UI thread.
221 void ShutdownOnUiThread(); 221 void ShutdownOnUiThread();
222 222
223 // Applies the host config, returning true if successful. 223 // Applies the host config, returning true if successful.
224 bool ApplyConfig(scoped_ptr<JsonHostConfig> config); 224 bool ApplyConfig(scoped_ptr<JsonHostConfig> config);
225 225
226 // Handles policy updates, by calling On*PolicyUpdate methods.
226 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies); 227 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies);
227 bool OnHostDomainPolicyUpdate(const std::string& host_domain); 228 void ApplyHostDomainPolicy();
228 bool OnUsernamePolicyUpdate(bool curtain_required, 229 void ApplyUsernamePolicy();
229 bool username_match_required); 230 bool OnHostDomainPolicyUpdate(base::DictionaryValue* policies);
230 bool OnNatPolicyUpdate(bool nat_traversal_enabled); 231 bool OnUsernamePolicyUpdate(base::DictionaryValue* policies);
231 bool OnRelayPolicyUpdate(bool allow_relay); 232 bool OnNatPolicyUpdate(base::DictionaryValue* policies);
232 bool OnUdpPortPolicyUpdate(const std::string& udp_port_range); 233 bool OnRelayPolicyUpdate(base::DictionaryValue* policies);
233 void OnCurtainPolicyUpdate(bool curtain_required); 234 bool OnUdpPortPolicyUpdate(base::DictionaryValue* policies);
234 bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix); 235 bool OnCurtainPolicyUpdate(base::DictionaryValue* policies);
235 bool OnHostTokenUrlPolicyUpdate( 236 bool OnHostTalkGadgetPrefixPolicyUpdate(base::DictionaryValue* policies);
236 const GURL& token_url, 237 bool OnHostTokenUrlPolicyUpdate(base::DictionaryValue* policies);
237 const GURL& token_validation_url, 238 bool OnPairingPolicyUpdate(base::DictionaryValue* policies);
238 const std::string& token_validation_cert_issuer); 239 bool OnGnubbyAuthPolicyUpdate(base::DictionaryValue* policies);
239 bool OnPairingPolicyUpdate(bool pairing_enabled);
240 bool OnGnubbyAuthPolicyUpdate(bool enable_gnubby_auth);
241 240
242 void StartHost(); 241 void StartHost();
243 242
244 void OnAuthFailed(); 243 void OnAuthFailed();
245 244
246 void RestartHost(); 245 void RestartHost();
247 246
248 // Stops the host and shuts down the process with the specified |exit_code|. 247 // Stops the host and shuts down the process with the specified |exit_code|.
249 void ShutdownHost(HostExitCodes exit_code); 248 void ShutdownHost(HostExitCodes exit_code);
250 249
(...skipping 30 matching lines...) Expand all
281 280
282 scoped_ptr<ConfigWatcher> config_watcher_; 281 scoped_ptr<ConfigWatcher> config_watcher_;
283 282
284 std::string host_id_; 283 std::string host_id_;
285 protocol::SharedSecretHash host_secret_hash_; 284 protocol::SharedSecretHash host_secret_hash_;
286 scoped_refptr<RsaKeyPair> key_pair_; 285 scoped_refptr<RsaKeyPair> key_pair_;
287 std::string oauth_refresh_token_; 286 std::string oauth_refresh_token_;
288 std::string serialized_config_; 287 std::string serialized_config_;
289 std::string host_owner_; 288 std::string host_owner_;
290 bool use_service_account_; 289 bool use_service_account_;
290
rmsousa 2014/06/06 23:23:14 empty line separates config variables from policy
291 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; 291 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_;
292 std::string host_domain_;
293 bool host_username_match_required_;
292 bool allow_nat_traversal_; 294 bool allow_nat_traversal_;
293 bool allow_relay_; 295 bool allow_relay_;
294 int min_udp_port_; 296 int min_udp_port_;
295 int max_udp_port_; 297 int max_udp_port_;
296 std::string talkgadget_prefix_; 298 std::string talkgadget_prefix_;
297 bool allow_pairing_; 299 bool allow_pairing_;
298 300
299 bool curtain_required_; 301 bool curtain_required_;
300 ThirdPartyAuthConfig third_party_auth_config_; 302 ThirdPartyAuthConfig third_party_auth_config_;
301 bool enable_gnubby_auth_; 303 bool enable_gnubby_auth_;
(...skipping 20 matching lines...) Expand all
322 bool signal_parent_; 324 bool signal_parent_;
323 325
324 scoped_ptr<PairingRegistry::Delegate> pairing_registry_delegate_; 326 scoped_ptr<PairingRegistry::Delegate> pairing_registry_delegate_;
325 }; 327 };
326 328
327 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, 329 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context,
328 int* exit_code_out) 330 int* exit_code_out)
329 : context_(context.Pass()), 331 : context_(context.Pass()),
330 state_(HOST_INITIALIZING), 332 state_(HOST_INITIALIZING),
331 use_service_account_(false), 333 use_service_account_(false),
334 host_username_match_required_(false),
332 allow_nat_traversal_(true), 335 allow_nat_traversal_(true),
333 allow_relay_(true), 336 allow_relay_(true),
334 min_udp_port_(0), 337 min_udp_port_(0),
335 max_udp_port_(0), 338 max_udp_port_(0),
336 allow_pairing_(true), 339 allow_pairing_(true),
337 curtain_required_(false), 340 curtain_required_(false),
338 enable_gnubby_auth_(false), 341 enable_gnubby_auth_(false),
339 #if defined(REMOTING_MULTI_PROCESS) 342 #if defined(REMOTING_MULTI_PROCESS)
340 desktop_session_connector_(NULL), 343 desktop_session_connector_(NULL),
341 #endif // defined(REMOTING_MULTI_PROCESS) 344 #endif // defined(REMOTING_MULTI_PROCESS)
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 478
476 if (state_ == HOST_INITIALIZING) { 479 if (state_ == HOST_INITIALIZING) {
477 // TODO(sergeyu): Currently OnPolicyUpdate() assumes that host config is 480 // TODO(sergeyu): Currently OnPolicyUpdate() assumes that host config is
478 // already loaded so PolicyWatcher has to be started here. Separate policy 481 // already loaded so PolicyWatcher has to be started here. Separate policy
479 // loading from policy verifications and move |policy_watcher_| 482 // loading from policy verifications and move |policy_watcher_|
480 // initialization to StartOnNetworkThread(). 483 // initialization to StartOnNetworkThread().
481 policy_watcher_.reset( 484 policy_watcher_.reset(
482 policy_hack::PolicyWatcher::Create(context_->file_task_runner())); 485 policy_hack::PolicyWatcher::Create(context_->file_task_runner()));
483 policy_watcher_->StartWatching( 486 policy_watcher_->StartWatching(
484 base::Bind(&HostProcess::OnPolicyUpdate, base::Unretained(this))); 487 base::Bind(&HostProcess::OnPolicyUpdate, base::Unretained(this)));
485 } else if (state_ == HOST_STARTED) { 488 } else {
486 // TODO(sergeyu): Here we assume that PIN is the only part of the config 489 // Reapply policies that could be affected by a new config.
487 // that may change while the service is running. Change ApplyConfig() to 490 ApplyHostDomainPolicy();
488 // detect other changes in the config and restart host if necessary here. 491 ApplyUsernamePolicy();
489 CreateAuthenticatorFactory(); 492
493 if (state_ == HOST_STARTED) {
494 // TODO(sergeyu): Here we assume that PIN is the only part of the config
495 // that may change while the service is running. Change ApplyConfig() to
496 // detect other changes in the config and restart host if necessary here.
497 CreateAuthenticatorFactory();
498 }
490 } 499 }
491 } 500 }
492 501
493 void HostProcess::OnConfigWatcherError() { 502 void HostProcess::OnConfigWatcherError() {
494 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 503 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
495 ShutdownHost(kInvalidHostConfigurationExitCode); 504 ShutdownHost(kInvalidHostConfigurationExitCode);
496 } 505 }
497 506
498 void HostProcess::StartOnNetworkThread() { 507 void HostProcess::StartOnNetworkThread() {
499 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 508 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 use_service_account_ = true; 813 use_service_account_ = true;
805 } else { 814 } else {
806 // User credential configs only have an xmpp_login, which is also the owner. 815 // User credential configs only have an xmpp_login, which is also the owner.
807 host_owner_ = xmpp_server_config_.username; 816 host_owner_ = xmpp_server_config_.username;
808 use_service_account_ = false; 817 use_service_account_ = false;
809 } 818 }
810 return true; 819 return true;
811 } 820 }
812 821
813 void HostProcess::OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) { 822 void HostProcess::OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) {
814 // TODO(rmsousa): Consolidate all On*PolicyUpdate methods into this one.
815 // TODO(sergeyu): Currently polices are verified only when they are loaded.
816 // Separate policy loading from policy verifications - this will allow to
817 // check policies again later, e.g. when host config changes.
818
819 if (!context_->network_task_runner()->BelongsToCurrentThread()) { 823 if (!context_->network_task_runner()->BelongsToCurrentThread()) {
820 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind( 824 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
821 &HostProcess::OnPolicyUpdate, this, base::Passed(&policies))); 825 &HostProcess::OnPolicyUpdate, this, base::Passed(&policies)));
822 return; 826 return;
823 } 827 }
824 828
825 bool restart_required = false; 829 bool restart_required = false;
826 bool bool_value; 830 restart_required |= OnHostDomainPolicyUpdate(policies.get());
827 std::string string_value; 831 restart_required |= OnCurtainPolicyUpdate(policies.get());
828 if (policies->GetString(policy_hack::PolicyWatcher::kHostDomainPolicyName, 832 // Note: UsernamePolicyUpdate must run after OnCurtainPolicyUpdate.
829 &string_value)) { 833 restart_required |= OnUsernamePolicyUpdate(policies.get());
830 restart_required |= OnHostDomainPolicyUpdate(string_value); 834 restart_required |= OnNatPolicyUpdate(policies.get());
831 } 835 restart_required |= OnRelayPolicyUpdate(policies.get());
832 bool curtain_required = false; 836 restart_required |= OnUdpPortPolicyUpdate(policies.get());
833 if (policies->GetBoolean( 837 restart_required |= OnHostTalkGadgetPrefixPolicyUpdate(policies.get());
834 policy_hack::PolicyWatcher::kHostRequireCurtainPolicyName, 838 restart_required |= OnHostTokenUrlPolicyUpdate(policies.get());
835 &curtain_required)) { 839 restart_required |= OnPairingPolicyUpdate(policies.get());
836 OnCurtainPolicyUpdate(curtain_required); 840 restart_required |= OnGnubbyAuthPolicyUpdate(policies.get());
837 }
838 if (policies->GetBoolean(
839 policy_hack::PolicyWatcher::kHostMatchUsernamePolicyName,
840 &bool_value)) {
841 restart_required |= OnUsernamePolicyUpdate(curtain_required, bool_value);
842 }
843 if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName,
844 &bool_value)) {
845 restart_required |= OnNatPolicyUpdate(bool_value);
846 }
847 if (policies->GetBoolean(policy_hack::PolicyWatcher::kRelayPolicyName,
848 &bool_value)) {
849 restart_required |= OnRelayPolicyUpdate(bool_value);
850 }
851 std::string udp_port_range;
852 if (policies->GetString(policy_hack::PolicyWatcher::kUdpPortRangePolicyName,
853 &udp_port_range)) {
854 restart_required |= OnUdpPortPolicyUpdate(udp_port_range);
855 }
856
857 if (policies->GetString(
858 policy_hack::PolicyWatcher::kHostTalkGadgetPrefixPolicyName,
859 &string_value)) {
860 restart_required |= OnHostTalkGadgetPrefixPolicyUpdate(string_value);
861 }
862 std::string token_url_string, token_validation_url_string;
863 std::string token_validation_cert_issuer;
864 if (policies->GetString(
865 policy_hack::PolicyWatcher::kHostTokenUrlPolicyName,
866 &token_url_string) &&
867 policies->GetString(
868 policy_hack::PolicyWatcher::kHostTokenValidationUrlPolicyName,
869 &token_validation_url_string) &&
870 policies->GetString(
871 policy_hack::PolicyWatcher::kHostTokenValidationCertIssuerPolicyName,
872 &token_validation_cert_issuer)) {
873 restart_required |= OnHostTokenUrlPolicyUpdate(
874 GURL(token_url_string), GURL(token_validation_url_string),
875 token_validation_cert_issuer);
876 }
877 if (policies->GetBoolean(
878 policy_hack::PolicyWatcher::kHostAllowClientPairing,
879 &bool_value)) {
880 restart_required |= OnPairingPolicyUpdate(bool_value);
881 }
882 if (policies->GetBoolean(
883 policy_hack::PolicyWatcher::kHostAllowGnubbyAuthPolicyName,
884 &bool_value))
885 restart_required |= OnGnubbyAuthPolicyUpdate(bool_value);
886 841
887 if (state_ == HOST_INITIALIZING) { 842 if (state_ == HOST_INITIALIZING) {
888 StartHost(); 843 StartHost();
889 } else if (state_ == HOST_STARTED && restart_required) { 844 } else if (state_ == HOST_STARTED && restart_required) {
890 RestartHost(); 845 RestartHost();
891 } 846 }
892 } 847 }
893 848
894 bool HostProcess::OnHostDomainPolicyUpdate(const std::string& host_domain) { 849 void HostProcess::ApplyHostDomainPolicy() {
850 HOST_LOG << "Policy sets host domain: " << host_domain_;
851 if (!host_domain_.empty() &&
852 !EndsWith(host_owner_, std::string("@") + host_domain_, false)) {
853 LOG(ERROR) << "The host domain does not match the policy.";
854 ShutdownHost(kInvalidHostDomainExitCode);
855 }
856 }
857
858 bool HostProcess::OnHostDomainPolicyUpdate(base::DictionaryValue* policies) {
895 // Returns true if the host has to be restarted after this policy update. 859 // Returns true if the host has to be restarted after this policy update.
896 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 860 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
897 861
898 HOST_LOG << "Policy sets host domain: " << host_domain; 862 if (!policies->GetString(policy_hack::PolicyWatcher::kHostDomainPolicyName,
863 &host_domain_)) {
864 return false;
865 }
899 866
900 if (!host_domain.empty() && 867 ApplyHostDomainPolicy();
901 !EndsWith(host_owner_, std::string("@") + host_domain, false)) {
902 ShutdownHost(kInvalidHostDomainExitCode);
903 }
904 return false; 868 return false;
905 } 869 }
906 870
907 bool HostProcess::OnUsernamePolicyUpdate(bool curtain_required, 871 void HostProcess::ApplyUsernamePolicy() {
908 bool host_username_match_required) { 872 if (host_username_match_required_) {
909 // Returns false: never restart the host after this policy update.
910 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
911
912 if (host_username_match_required) {
913 HOST_LOG << "Policy requires host username match."; 873 HOST_LOG << "Policy requires host username match.";
914 std::string username = GetUsername(); 874 std::string username = GetUsername();
915 bool shutdown = username.empty() || 875 bool shutdown = username.empty() ||
916 !StartsWithASCII(host_owner_, username + std::string("@"), 876 !StartsWithASCII(host_owner_, username + std::string("@"),
917 false); 877 false);
918 878
919 #if defined(OS_MACOSX) 879 #if defined(OS_MACOSX)
920 // On Mac, we run as root at the login screen, so the username won't match. 880 // On Mac, we run as root at the login screen, so the username won't match.
921 // However, there's no need to enforce the policy at the login screen, as 881 // However, there's no need to enforce the policy at the login screen, as
922 // the client will have to reconnect if a login occurs. 882 // the client will have to reconnect if a login occurs.
923 if (shutdown && getuid() == 0) { 883 if (shutdown && getuid() == 0) {
924 shutdown = false; 884 shutdown = false;
925 } 885 }
926 #endif 886 #endif
927 887
928 // Curtain-mode on Windows presents the standard OS login prompt to the user 888 // Curtain-mode on Windows presents the standard OS login prompt to the user
929 // for each connection, removing the need for an explicit user-name matching 889 // for each connection, removing the need for an explicit user-name matching
930 // check. 890 // check.
931 #if defined(OS_WIN) && defined(REMOTING_RDP_SESSION) 891 #if defined(OS_WIN) && defined(REMOTING_RDP_SESSION)
932 if (curtain_required) 892 if (curtain_required_)
933 return false; 893 return false;
934 #endif // defined(OS_WIN) && defined(REMOTING_RDP_SESSION) 894 #endif // defined(OS_WIN) && defined(REMOTING_RDP_SESSION)
935 895
936 // Shutdown the host if the username does not match. 896 // Shutdown the host if the username does not match.
937 if (shutdown) { 897 if (shutdown) {
938 LOG(ERROR) << "The host username does not match."; 898 LOG(ERROR) << "The host username does not match.";
939 ShutdownHost(kUsernameMismatchExitCode); 899 ShutdownHost(kUsernameMismatchExitCode);
940 } 900 }
941 } else { 901 } else {
942 HOST_LOG << "Policy does not require host username match."; 902 HOST_LOG << "Policy does not require host username match.";
943 } 903 }
904 }
944 905
906 bool HostProcess::OnUsernamePolicyUpdate(base::DictionaryValue* policies) {
907 // Returns false: never restart the host after this policy update.
908 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
909
910 if (!policies->GetBoolean(
911 policy_hack::PolicyWatcher::kHostMatchUsernamePolicyName,
912 &host_username_match_required_)) {
913 return false;
914 }
915
916 ApplyUsernamePolicy();
945 return false; 917 return false;
946 } 918 }
947 919
948 bool HostProcess::OnNatPolicyUpdate(bool nat_traversal_enabled) { 920 bool HostProcess::OnNatPolicyUpdate(base::DictionaryValue* policies) {
949 // Returns true if the host has to be restarted after this policy update. 921 // Returns true if the host has to be restarted after this policy update.
950 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 922 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
951 923
952 if (allow_nat_traversal_ != nat_traversal_enabled) { 924 if (!policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName,
953 if (nat_traversal_enabled) 925 &allow_nat_traversal_)) {
954 HOST_LOG << "Policy enables NAT traversal."; 926 return false;
955 else
956 HOST_LOG << "Policy disables NAT traversal.";
957 allow_nat_traversal_ = nat_traversal_enabled;
958 return true;
959 } 927 }
960 return false; 928
929 if (allow_nat_traversal_)
930 HOST_LOG << "Policy enables NAT traversal.";
Sergey Ulanov 2014/06/07 00:51:44 add {} please
rmsousa 2014/06/07 01:09:03 Done.
931 else
932 HOST_LOG << "Policy disables NAT traversal.";
933 return true;
961 } 934 }
962 935
963 bool HostProcess::OnRelayPolicyUpdate(bool allow_relay) { 936 bool HostProcess::OnRelayPolicyUpdate(base::DictionaryValue* policies) {
964 // Returns true if the host has to be restarted after this policy update. 937 // Returns true if the host has to be restarted after this policy update.
965 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 938 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
966 939
967 if (allow_relay_ != allow_relay) { 940 if (!policies->GetBoolean(policy_hack::PolicyWatcher::kRelayPolicyName,
968 if (allow_relay) 941 &allow_relay_)) {
969 HOST_LOG << "Policy enables use of relay server."; 942 return false;
970 else
971 HOST_LOG << "Policy disables use of relay server.";
972 allow_relay_ = allow_relay;
973 return true;
974 } 943 }
975 return false; 944
945 if (allow_relay_)
946 HOST_LOG << "Policy enables use of relay server.";
947 else
948 HOST_LOG << "Policy disables use of relay server.";
949 return true;
976 } 950 }
977 951
978 bool HostProcess::OnUdpPortPolicyUpdate(const std::string& udp_port_range) { 952 bool HostProcess::OnUdpPortPolicyUpdate(base::DictionaryValue* policies) {
979 // Returns true if the host has to be restarted after this policy update. 953 // Returns true if the host has to be restarted after this policy update.
980 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 954 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
981 955
956 std::string udp_port_range;
957 if (!policies->GetString(policy_hack::PolicyWatcher::kUdpPortRangePolicyName,
958 &udp_port_range)) {
959 return false;
960 }
961
982 // Use default values if policy setting is empty or invalid. 962 // Use default values if policy setting is empty or invalid.
983 int min_udp_port = 0; 963 int min_udp_port = 0;
984 int max_udp_port = 0; 964 int max_udp_port = 0;
985 if (!udp_port_range.empty() && 965 if (!udp_port_range.empty() &&
986 !NetworkSettings::ParsePortRange(udp_port_range, &min_udp_port, 966 !NetworkSettings::ParsePortRange(udp_port_range, &min_udp_port,
987 &max_udp_port)) { 967 &max_udp_port)) {
988 LOG(WARNING) << "Invalid port range policy: \"" << udp_port_range 968 LOG(WARNING) << "Invalid port range policy: \"" << udp_port_range
989 << "\". Using default values."; 969 << "\". Using default values.";
990 } 970 }
991 971
992 if (min_udp_port_ != min_udp_port || max_udp_port_ != max_udp_port) { 972 if (min_udp_port_ != min_udp_port || max_udp_port_ != max_udp_port) {
993 if (min_udp_port != 0 && max_udp_port != 0) { 973 if (min_udp_port != 0 && max_udp_port != 0) {
994 HOST_LOG << "Policy restricts UDP port range to [" << min_udp_port 974 HOST_LOG << "Policy restricts UDP port range to [" << min_udp_port
995 << ", " << max_udp_port << "]"; 975 << ", " << max_udp_port << "]";
996 } else { 976 } else {
997 HOST_LOG << "Policy does not restrict UDP port range."; 977 HOST_LOG << "Policy does not restrict UDP port range.";
998 } 978 }
999 min_udp_port_ = min_udp_port; 979 min_udp_port_ = min_udp_port;
1000 max_udp_port_ = max_udp_port; 980 max_udp_port_ = max_udp_port;
1001 return true; 981 return true;
1002 } 982 }
1003 return false; 983 return false;
1004 } 984 }
1005 985
1006 void HostProcess::OnCurtainPolicyUpdate(bool curtain_required) { 986 bool HostProcess::OnCurtainPolicyUpdate(base::DictionaryValue* policies) {
1007 // Returns true if the host has to be restarted after this policy update. 987 // Returns true if the host has to be restarted after this policy update.
1008 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 988 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
1009 989
990 if (!policies->GetBoolean(
991 policy_hack::PolicyWatcher::kHostRequireCurtainPolicyName,
992 &curtain_required_)) {
993 return false;
994 }
995
1010 #if defined(OS_MACOSX) 996 #if defined(OS_MACOSX)
1011 if (curtain_required) { 997 if (curtain_required_) {
1012 // When curtain mode is in effect on Mac, the host process runs in the 998 // When curtain mode is in effect on Mac, the host process runs in the
1013 // user's switched-out session, but launchd will also run an instance at 999 // user's switched-out session, but launchd will also run an instance at
1014 // the console login screen. Even if no user is currently logged-on, we 1000 // the console login screen. Even if no user is currently logged-on, we
1015 // can't support remote-access to the login screen because the current host 1001 // can't support remote-access to the login screen because the current host
1016 // process model disconnects the client during login, which would leave 1002 // process model disconnects the client during login, which would leave
1017 // the logged in session un-curtained on the console until they reconnect. 1003 // the logged in session un-curtained on the console until they reconnect.
1018 // 1004 //
1019 // TODO(jamiewalch): Fix this once we have implemented the multi-process 1005 // TODO(jamiewalch): Fix this once we have implemented the multi-process
1020 // daemon architecture (crbug.com/134894) 1006 // daemon architecture (crbug.com/134894)
1021 if (getuid() == 0) { 1007 if (getuid() == 0) {
1022 LOG(ERROR) << "Running the host in the console login session is yet not " 1008 LOG(ERROR) << "Running the host in the console login session is yet not "
1023 "supported."; 1009 "supported.";
1024 ShutdownHost(kLoginScreenNotSupportedExitCode); 1010 ShutdownHost(kLoginScreenNotSupportedExitCode);
1025 return; 1011 return false;
1026 } 1012 }
1027 } 1013 }
1028 #endif 1014 #endif
1029 1015
1030 if (curtain_required_ != curtain_required) { 1016 if (curtain_required_)
1031 if (curtain_required) 1017 HOST_LOG << "Policy requires curtain-mode.";
1032 HOST_LOG << "Policy requires curtain-mode."; 1018 else
1033 else 1019 HOST_LOG << "Policy does not require curtain-mode.";
1034 HOST_LOG << "Policy does not require curtain-mode."; 1020
1035 curtain_required_ = curtain_required; 1021 if (host_)
1036 if (host_) 1022 host_->SetEnableCurtaining(curtain_required_);
1037 host_->SetEnableCurtaining(curtain_required_); 1023 return false;
1038 }
1039 } 1024 }
1040 1025
1041 bool HostProcess::OnHostTalkGadgetPrefixPolicyUpdate( 1026 bool HostProcess::OnHostTalkGadgetPrefixPolicyUpdate(
1042 const std::string& talkgadget_prefix) { 1027 base::DictionaryValue* policies) {
1043 // Returns true if the host has to be restarted after this policy update. 1028 // Returns true if the host has to be restarted after this policy update.
1044 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 1029 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
1045 1030
1046 if (talkgadget_prefix != talkgadget_prefix_) { 1031 if (!policies->GetString(
1047 HOST_LOG << "Policy sets talkgadget prefix: " << talkgadget_prefix; 1032 policy_hack::PolicyWatcher::kHostTalkGadgetPrefixPolicyName,
1048 talkgadget_prefix_ = talkgadget_prefix; 1033 &talkgadget_prefix_)) {
1049 return true; 1034 return false;
1050 } 1035 }
1051 return false; 1036
1037 HOST_LOG << "Policy sets talkgadget prefix: " << talkgadget_prefix_;
1038 return true;
1052 } 1039 }
1053 1040
1054 bool HostProcess::OnHostTokenUrlPolicyUpdate( 1041 bool HostProcess::OnHostTokenUrlPolicyUpdate(base::DictionaryValue* policies) {
1055 const GURL& token_url,
1056 const GURL& token_validation_url,
1057 const std::string& token_validation_cert_issuer) {
1058 // Returns true if the host has to be restarted after this policy update. 1042 // Returns true if the host has to be restarted after this policy update.
1059 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 1043 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
1060 1044
1061 if (third_party_auth_config_.token_url != token_url || 1045 bool token_policy_changed = false;
1062 third_party_auth_config_.token_validation_url != token_validation_url || 1046 std::string token_url_string;
1063 third_party_auth_config_.token_validation_cert_issuer != 1047 if (policies->GetString(
1064 token_validation_cert_issuer) { 1048 policy_hack::PolicyWatcher::kHostTokenUrlPolicyName,
1065 HOST_LOG << "Policy sets third-party token URLs: " 1049 &token_url_string)) {
1066 << "TokenUrl: " << token_url << ", " 1050 token_policy_changed = true;
1067 << "TokenValidationUrl: " << token_validation_url 1051 third_party_auth_config_.token_url = GURL(token_url_string);
1068 << "TokenValidationCertificateIssuer: " 1052 }
1069 << token_validation_cert_issuer; 1053 std::string token_validation_url_string;
1070 third_party_auth_config_.token_url = token_url; 1054 if (policies->GetString(
1071 third_party_auth_config_.token_validation_url = token_validation_url; 1055 policy_hack::PolicyWatcher::kHostTokenValidationUrlPolicyName,
1072 third_party_auth_config_.token_validation_cert_issuer = 1056 &token_validation_url_string)) {
1073 token_validation_cert_issuer; 1057 token_policy_changed = true;
1074 return true; 1058 third_party_auth_config_.token_validation_url =
1059 GURL(token_validation_url_string);
1060 }
1061 if (policies->GetString(
1062 policy_hack::PolicyWatcher::kHostTokenValidationCertIssuerPolicyName,
1063 &third_party_auth_config_.token_validation_cert_issuer)) {
1064 token_policy_changed = true;
1075 } 1065 }
1076 1066
1077 return false; 1067 if (token_policy_changed) {
1068 HOST_LOG << "Policy sets third-party token URLs: "
1069 << "TokenUrl: "
1070 << third_party_auth_config_.token_url << ", "
1071 << "TokenValidationUrl: "
1072 << third_party_auth_config_.token_validation_url << ", "
1073 << "TokenValidationCertificateIssuer: "
1074 << third_party_auth_config_.token_validation_cert_issuer;
1075 }
1076 return token_policy_changed;
1078 } 1077 }
1079 1078
1080 bool HostProcess::OnPairingPolicyUpdate(bool allow_pairing) { 1079 bool HostProcess::OnPairingPolicyUpdate(base::DictionaryValue* policies) {
1081 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 1080 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
1082 1081
1083 if (allow_pairing_ == allow_pairing) 1082 if (!policies->GetBoolean(
1083 policy_hack::PolicyWatcher::kHostAllowClientPairing,
1084 &allow_pairing_)) {
1084 return false; 1085 return false;
1086 }
1085 1087
1086 if (allow_pairing) 1088 if (allow_pairing_)
1087 HOST_LOG << "Policy enables client pairing."; 1089 HOST_LOG << "Policy enables client pairing.";
Sergey Ulanov 2014/06/07 00:51:45 add {} please
rmsousa 2014/06/07 01:09:03 Done.
1088 else 1090 else
1089 HOST_LOG << "Policy disables client pairing."; 1091 HOST_LOG << "Policy disables client pairing.";
1090 allow_pairing_ = allow_pairing;
1091 return true; 1092 return true;
1092 } 1093 }
1093 1094
1094 bool HostProcess::OnGnubbyAuthPolicyUpdate(bool enable_gnubby_auth) { 1095 bool HostProcess::OnGnubbyAuthPolicyUpdate(base::DictionaryValue* policies) {
1095 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 1096 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
1096 1097
1097 if (enable_gnubby_auth_ == enable_gnubby_auth) 1098 if (!policies->GetBoolean(
1099 policy_hack::PolicyWatcher::kHostAllowGnubbyAuthPolicyName,
1100 &enable_gnubby_auth_)) {
1098 return false; 1101 return false;
1102 }
1099 1103
1100 if (enable_gnubby_auth) { 1104 if (enable_gnubby_auth_) {
1101 HOST_LOG << "Policy enables gnubby auth."; 1105 HOST_LOG << "Policy enables gnubby auth.";
1102 } else { 1106 } else {
1103 HOST_LOG << "Policy disables gnubby auth."; 1107 HOST_LOG << "Policy disables gnubby auth.";
1104 } 1108 }
1105 enable_gnubby_auth_ = enable_gnubby_auth;
1106 1109
1107 if (desktop_environment_factory_) 1110 if (desktop_environment_factory_)
1108 desktop_environment_factory_->SetEnableGnubbyAuth(enable_gnubby_auth); 1111 desktop_environment_factory_->SetEnableGnubbyAuth(enable_gnubby_auth_);
1109 1112
1110 return true; 1113 return true;
1111 } 1114 }
1112 1115
1113 void HostProcess::StartHost() { 1116 void HostProcess::StartHost() {
1114 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 1117 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
1115 DCHECK(!host_); 1118 DCHECK(!host_);
1116 DCHECK(!signal_strategy_.get()); 1119 DCHECK(!signal_strategy_.get());
1117 DCHECK(state_ == HOST_INITIALIZING || state_ == HOST_STOPPING_TO_RESTART || 1120 DCHECK(state_ == HOST_INITIALIZING || state_ == HOST_STOPPING_TO_RESTART ||
1118 state_ == HOST_STOPPED) << state_; 1121 state_ == HOST_STOPPED) << state_;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 return exit_code; 1356 return exit_code;
1354 } 1357 }
1355 1358
1356 } // namespace remoting 1359 } // namespace remoting
1357 1360
1358 #if !defined(OS_WIN) 1361 #if !defined(OS_WIN)
1359 int main(int argc, char** argv) { 1362 int main(int argc, char** argv) {
1360 return remoting::HostMain(argc, argv); 1363 return remoting::HostMain(argc, argv);
1361 } 1364 }
1362 #endif // !defined(OS_WIN) 1365 #endif // !defined(OS_WIN)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698