OLD | NEW |
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 12 matching lines...) Expand all Loading... |
23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
24 #include "crypto/nss_util.h" | 24 #include "crypto/nss_util.h" |
25 #include "ipc/ipc_channel.h" | 25 #include "ipc/ipc_channel.h" |
26 #include "ipc/ipc_channel_proxy.h" | 26 #include "ipc/ipc_channel_proxy.h" |
27 #include "ipc/ipc_listener.h" | 27 #include "ipc/ipc_listener.h" |
28 #include "media/base/media.h" | 28 #include "media/base/media.h" |
29 #include "net/base/network_change_notifier.h" | 29 #include "net/base/network_change_notifier.h" |
30 #include "net/socket/client_socket_factory.h" | 30 #include "net/socket/client_socket_factory.h" |
31 #include "net/socket/ssl_server_socket.h" | 31 #include "net/socket/ssl_server_socket.h" |
32 #include "net/url_request/url_fetcher.h" | 32 #include "net/url_request/url_fetcher.h" |
| 33 #include "policy/policy_constants.h" |
33 #include "remoting/base/auto_thread_task_runner.h" | 34 #include "remoting/base/auto_thread_task_runner.h" |
34 #include "remoting/base/breakpad.h" | 35 #include "remoting/base/breakpad.h" |
35 #include "remoting/base/constants.h" | 36 #include "remoting/base/constants.h" |
36 #include "remoting/base/logging.h" | 37 #include "remoting/base/logging.h" |
37 #include "remoting/base/rsa_key_pair.h" | 38 #include "remoting/base/rsa_key_pair.h" |
38 #include "remoting/base/service_urls.h" | 39 #include "remoting/base/service_urls.h" |
39 #include "remoting/base/util.h" | 40 #include "remoting/base/util.h" |
40 #include "remoting/host/branding.h" | 41 #include "remoting/host/branding.h" |
41 #include "remoting/host/chromoting_host.h" | 42 #include "remoting/host/chromoting_host.h" |
42 #include "remoting/host/chromoting_host_context.h" | 43 #include "remoting/host/chromoting_host_context.h" |
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 LOG(ERROR) << "The host domain does not match the policy."; | 974 LOG(ERROR) << "The host domain does not match the policy."; |
974 ShutdownHost(kInvalidHostDomainExitCode); | 975 ShutdownHost(kInvalidHostDomainExitCode); |
975 } | 976 } |
976 } | 977 } |
977 } | 978 } |
978 | 979 |
979 bool HostProcess::OnHostDomainPolicyUpdate(base::DictionaryValue* policies) { | 980 bool HostProcess::OnHostDomainPolicyUpdate(base::DictionaryValue* policies) { |
980 // Returns true if the host has to be restarted after this policy update. | 981 // Returns true if the host has to be restarted after this policy update. |
981 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 982 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
982 | 983 |
983 if (!policies->GetString(policy_hack::PolicyWatcher::kHostDomainPolicyName, | 984 if (!policies->GetString(policy::key::kRemoteAccessHostDomain, |
984 &host_domain_)) { | 985 &host_domain_)) { |
985 return false; | 986 return false; |
986 } | 987 } |
987 | 988 |
988 ApplyHostDomainPolicy(); | 989 ApplyHostDomainPolicy(); |
989 return false; | 990 return false; |
990 } | 991 } |
991 | 992 |
992 void HostProcess::ApplyUsernamePolicy() { | 993 void HostProcess::ApplyUsernamePolicy() { |
993 if (host_username_match_required_) { | 994 if (host_username_match_required_) { |
994 HOST_LOG << "Policy requires host username match."; | 995 HOST_LOG << "Policy requires host username match."; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 } | 1030 } |
1030 } else { | 1031 } else { |
1031 HOST_LOG << "Policy does not require host username match."; | 1032 HOST_LOG << "Policy does not require host username match."; |
1032 } | 1033 } |
1033 } | 1034 } |
1034 | 1035 |
1035 bool HostProcess::OnUsernamePolicyUpdate(base::DictionaryValue* policies) { | 1036 bool HostProcess::OnUsernamePolicyUpdate(base::DictionaryValue* policies) { |
1036 // Returns false: never restart the host after this policy update. | 1037 // Returns false: never restart the host after this policy update. |
1037 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 1038 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
1038 | 1039 |
1039 if (!policies->GetBoolean( | 1040 if (!policies->GetBoolean(policy::key::kRemoteAccessHostMatchUsername, |
1040 policy_hack::PolicyWatcher::kHostMatchUsernamePolicyName, | 1041 &host_username_match_required_)) { |
1041 &host_username_match_required_)) { | |
1042 return false; | 1042 return false; |
1043 } | 1043 } |
1044 | 1044 |
1045 ApplyUsernamePolicy(); | 1045 ApplyUsernamePolicy(); |
1046 return false; | 1046 return false; |
1047 } | 1047 } |
1048 | 1048 |
1049 bool HostProcess::OnNatPolicyUpdate(base::DictionaryValue* policies) { | 1049 bool HostProcess::OnNatPolicyUpdate(base::DictionaryValue* policies) { |
1050 // Returns true if the host has to be restarted after this policy update. | 1050 // Returns true if the host has to be restarted after this policy update. |
1051 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 1051 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
1052 | 1052 |
1053 if (!policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName, | 1053 if (!policies->GetBoolean(policy::key::kRemoteAccessHostFirewallTraversal, |
1054 &allow_nat_traversal_)) { | 1054 &allow_nat_traversal_)) { |
1055 return false; | 1055 return false; |
1056 } | 1056 } |
1057 | 1057 |
1058 if (allow_nat_traversal_) { | 1058 if (allow_nat_traversal_) { |
1059 HOST_LOG << "Policy enables NAT traversal."; | 1059 HOST_LOG << "Policy enables NAT traversal."; |
1060 } else { | 1060 } else { |
1061 HOST_LOG << "Policy disables NAT traversal."; | 1061 HOST_LOG << "Policy disables NAT traversal."; |
1062 } | 1062 } |
1063 return true; | 1063 return true; |
1064 } | 1064 } |
1065 | 1065 |
1066 bool HostProcess::OnRelayPolicyUpdate(base::DictionaryValue* policies) { | 1066 bool HostProcess::OnRelayPolicyUpdate(base::DictionaryValue* policies) { |
1067 // Returns true if the host has to be restarted after this policy update. | 1067 // Returns true if the host has to be restarted after this policy update. |
1068 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 1068 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
1069 | 1069 |
1070 if (!policies->GetBoolean(policy_hack::PolicyWatcher::kRelayPolicyName, | 1070 if (!policies->GetBoolean( |
1071 &allow_relay_)) { | 1071 policy::key::kRemoteAccessHostAllowRelayedConnection, |
| 1072 &allow_relay_)) { |
1072 return false; | 1073 return false; |
1073 } | 1074 } |
1074 | 1075 |
1075 if (allow_relay_) { | 1076 if (allow_relay_) { |
1076 HOST_LOG << "Policy enables use of relay server."; | 1077 HOST_LOG << "Policy enables use of relay server."; |
1077 } else { | 1078 } else { |
1078 HOST_LOG << "Policy disables use of relay server."; | 1079 HOST_LOG << "Policy disables use of relay server."; |
1079 } | 1080 } |
1080 return true; | 1081 return true; |
1081 } | 1082 } |
1082 | 1083 |
1083 bool HostProcess::OnUdpPortPolicyUpdate(base::DictionaryValue* policies) { | 1084 bool HostProcess::OnUdpPortPolicyUpdate(base::DictionaryValue* policies) { |
1084 // Returns true if the host has to be restarted after this policy update. | 1085 // Returns true if the host has to be restarted after this policy update. |
1085 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 1086 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
1086 | 1087 |
1087 std::string udp_port_range; | 1088 std::string udp_port_range; |
1088 if (!policies->GetString(policy_hack::PolicyWatcher::kUdpPortRangePolicyName, | 1089 if (!policies->GetString(policy::key::kRemoteAccessHostUdpPortRange, |
1089 &udp_port_range)) { | 1090 &udp_port_range)) { |
1090 return false; | 1091 return false; |
1091 } | 1092 } |
1092 | 1093 |
1093 // Use default values if policy setting is empty or invalid. | 1094 // Use default values if policy setting is empty or invalid. |
1094 uint16 min_udp_port = 0; | 1095 uint16 min_udp_port = 0; |
1095 uint16 max_udp_port = 0; | 1096 uint16 max_udp_port = 0; |
1096 if (!udp_port_range.empty() && | 1097 if (!udp_port_range.empty() && |
1097 !NetworkSettings::ParsePortRange(udp_port_range, &min_udp_port, | 1098 !NetworkSettings::ParsePortRange(udp_port_range, &min_udp_port, |
1098 &max_udp_port)) { | 1099 &max_udp_port)) { |
(...skipping 12 matching lines...) Expand all Loading... |
1111 max_udp_port_ = max_udp_port; | 1112 max_udp_port_ = max_udp_port; |
1112 return true; | 1113 return true; |
1113 } | 1114 } |
1114 return false; | 1115 return false; |
1115 } | 1116 } |
1116 | 1117 |
1117 bool HostProcess::OnCurtainPolicyUpdate(base::DictionaryValue* policies) { | 1118 bool HostProcess::OnCurtainPolicyUpdate(base::DictionaryValue* policies) { |
1118 // Returns true if the host has to be restarted after this policy update. | 1119 // Returns true if the host has to be restarted after this policy update. |
1119 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 1120 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
1120 | 1121 |
1121 if (!policies->GetBoolean( | 1122 if (!policies->GetBoolean(policy::key::kRemoteAccessHostRequireCurtain, |
1122 policy_hack::PolicyWatcher::kHostRequireCurtainPolicyName, | 1123 &curtain_required_)) { |
1123 &curtain_required_)) { | |
1124 return false; | 1124 return false; |
1125 } | 1125 } |
1126 | 1126 |
1127 #if defined(OS_MACOSX) | 1127 #if defined(OS_MACOSX) |
1128 if (curtain_required_) { | 1128 if (curtain_required_) { |
1129 // When curtain mode is in effect on Mac, the host process runs in the | 1129 // When curtain mode is in effect on Mac, the host process runs in the |
1130 // user's switched-out session, but launchd will also run an instance at | 1130 // user's switched-out session, but launchd will also run an instance at |
1131 // the console login screen. Even if no user is currently logged-on, we | 1131 // the console login screen. Even if no user is currently logged-on, we |
1132 // can't support remote-access to the login screen because the current host | 1132 // can't support remote-access to the login screen because the current host |
1133 // process model disconnects the client during login, which would leave | 1133 // process model disconnects the client during login, which would leave |
(...skipping 19 matching lines...) Expand all Loading... |
1153 if (host_) | 1153 if (host_) |
1154 host_->SetEnableCurtaining(curtain_required_); | 1154 host_->SetEnableCurtaining(curtain_required_); |
1155 return false; | 1155 return false; |
1156 } | 1156 } |
1157 | 1157 |
1158 bool HostProcess::OnHostTalkGadgetPrefixPolicyUpdate( | 1158 bool HostProcess::OnHostTalkGadgetPrefixPolicyUpdate( |
1159 base::DictionaryValue* policies) { | 1159 base::DictionaryValue* policies) { |
1160 // Returns true if the host has to be restarted after this policy update. | 1160 // Returns true if the host has to be restarted after this policy update. |
1161 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 1161 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
1162 | 1162 |
1163 if (!policies->GetString( | 1163 if (!policies->GetString(policy::key::kRemoteAccessHostTalkGadgetPrefix, |
1164 policy_hack::PolicyWatcher::kHostTalkGadgetPrefixPolicyName, | 1164 &talkgadget_prefix_)) { |
1165 &talkgadget_prefix_)) { | |
1166 return false; | 1165 return false; |
1167 } | 1166 } |
1168 | 1167 |
1169 HOST_LOG << "Policy sets talkgadget prefix: " << talkgadget_prefix_; | 1168 HOST_LOG << "Policy sets talkgadget prefix: " << talkgadget_prefix_; |
1170 return true; | 1169 return true; |
1171 } | 1170 } |
1172 | 1171 |
1173 bool HostProcess::OnHostTokenUrlPolicyUpdate(base::DictionaryValue* policies) { | 1172 bool HostProcess::OnHostTokenUrlPolicyUpdate(base::DictionaryValue* policies) { |
1174 // Returns true if the host has to be restarted after this policy update. | 1173 // Returns true if the host has to be restarted after this policy update. |
1175 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 1174 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
1176 | 1175 |
1177 bool token_policy_changed = false; | 1176 bool token_policy_changed = false; |
1178 std::string token_url_string; | 1177 std::string token_url_string; |
1179 if (policies->GetString( | 1178 if (policies->GetString(policy::key::kRemoteAccessHostTokenUrl, |
1180 policy_hack::PolicyWatcher::kHostTokenUrlPolicyName, | 1179 &token_url_string)) { |
1181 &token_url_string)) { | |
1182 token_policy_changed = true; | 1180 token_policy_changed = true; |
1183 third_party_auth_config_.token_url = GURL(token_url_string); | 1181 third_party_auth_config_.token_url = GURL(token_url_string); |
1184 } | 1182 } |
1185 std::string token_validation_url_string; | 1183 std::string token_validation_url_string; |
1186 if (policies->GetString( | 1184 if (policies->GetString(policy::key::kRemoteAccessHostTokenValidationUrl, |
1187 policy_hack::PolicyWatcher::kHostTokenValidationUrlPolicyName, | 1185 &token_validation_url_string)) { |
1188 &token_validation_url_string)) { | |
1189 token_policy_changed = true; | 1186 token_policy_changed = true; |
1190 third_party_auth_config_.token_validation_url = | 1187 third_party_auth_config_.token_validation_url = |
1191 GURL(token_validation_url_string); | 1188 GURL(token_validation_url_string); |
1192 } | 1189 } |
1193 if (policies->GetString( | 1190 if (policies->GetString( |
1194 policy_hack::PolicyWatcher::kHostTokenValidationCertIssuerPolicyName, | 1191 policy::key::kRemoteAccessHostTokenValidationCertificateIssuer, |
1195 &third_party_auth_config_.token_validation_cert_issuer)) { | 1192 &third_party_auth_config_.token_validation_cert_issuer)) { |
1196 token_policy_changed = true; | 1193 token_policy_changed = true; |
1197 } | 1194 } |
1198 | 1195 |
1199 if (token_policy_changed) { | 1196 if (token_policy_changed) { |
1200 HOST_LOG << "Policy sets third-party token URLs: " | 1197 HOST_LOG << "Policy sets third-party token URLs: " |
1201 << "TokenUrl: " | 1198 << "TokenUrl: " |
1202 << third_party_auth_config_.token_url << ", " | 1199 << third_party_auth_config_.token_url << ", " |
1203 << "TokenValidationUrl: " | 1200 << "TokenValidationUrl: " |
1204 << third_party_auth_config_.token_validation_url << ", " | 1201 << third_party_auth_config_.token_validation_url << ", " |
1205 << "TokenValidationCertificateIssuer: " | 1202 << "TokenValidationCertificateIssuer: " |
1206 << third_party_auth_config_.token_validation_cert_issuer; | 1203 << third_party_auth_config_.token_validation_cert_issuer; |
1207 } | 1204 } |
1208 return token_policy_changed; | 1205 return token_policy_changed; |
1209 } | 1206 } |
1210 | 1207 |
1211 bool HostProcess::OnPairingPolicyUpdate(base::DictionaryValue* policies) { | 1208 bool HostProcess::OnPairingPolicyUpdate(base::DictionaryValue* policies) { |
1212 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 1209 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
1213 | 1210 |
1214 if (!policies->GetBoolean( | 1211 if (!policies->GetBoolean(policy::key::kRemoteAccessHostAllowClientPairing, |
1215 policy_hack::PolicyWatcher::kHostAllowClientPairing, | 1212 &allow_pairing_)) { |
1216 &allow_pairing_)) { | |
1217 return false; | 1213 return false; |
1218 } | 1214 } |
1219 | 1215 |
1220 if (allow_pairing_) { | 1216 if (allow_pairing_) { |
1221 HOST_LOG << "Policy enables client pairing."; | 1217 HOST_LOG << "Policy enables client pairing."; |
1222 } else { | 1218 } else { |
1223 HOST_LOG << "Policy disables client pairing."; | 1219 HOST_LOG << "Policy disables client pairing."; |
1224 } | 1220 } |
1225 return true; | 1221 return true; |
1226 } | 1222 } |
1227 | 1223 |
1228 bool HostProcess::OnGnubbyAuthPolicyUpdate(base::DictionaryValue* policies) { | 1224 bool HostProcess::OnGnubbyAuthPolicyUpdate(base::DictionaryValue* policies) { |
1229 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 1225 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
1230 | 1226 |
1231 if (!policies->GetBoolean( | 1227 if (!policies->GetBoolean(policy::key::kRemoteAccessHostAllowGnubbyAuth, |
1232 policy_hack::PolicyWatcher::kHostAllowGnubbyAuthPolicyName, | 1228 &enable_gnubby_auth_)) { |
1233 &enable_gnubby_auth_)) { | |
1234 return false; | 1229 return false; |
1235 } | 1230 } |
1236 | 1231 |
1237 if (enable_gnubby_auth_) { | 1232 if (enable_gnubby_auth_) { |
1238 HOST_LOG << "Policy enables gnubby auth."; | 1233 HOST_LOG << "Policy enables gnubby auth."; |
1239 } else { | 1234 } else { |
1240 HOST_LOG << "Policy disables gnubby auth."; | 1235 HOST_LOG << "Policy disables gnubby auth."; |
1241 } | 1236 } |
1242 | 1237 |
1243 if (desktop_environment_factory_) | 1238 if (desktop_environment_factory_) |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); | 1498 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); |
1504 new HostProcess(context.Pass(), &exit_code, &shutdown_watchdog); | 1499 new HostProcess(context.Pass(), &exit_code, &shutdown_watchdog); |
1505 | 1500 |
1506 // Run the main (also UI) message loop until the host no longer needs it. | 1501 // Run the main (also UI) message loop until the host no longer needs it. |
1507 message_loop.Run(); | 1502 message_loop.Run(); |
1508 | 1503 |
1509 return exit_code; | 1504 return exit_code; |
1510 } | 1505 } |
1511 | 1506 |
1512 } // namespace remoting | 1507 } // namespace remoting |
OLD | NEW |