| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 namespace { | 106 namespace { |
| 107 | 107 |
| 108 // This is used for tagging system event logs. | 108 // This is used for tagging system event logs. |
| 109 const char kApplicationName[] = "chromoting"; | 109 const char kApplicationName[] = "chromoting"; |
| 110 | 110 |
| 111 #if defined(OS_LINUX) | 111 #if defined(OS_LINUX) |
| 112 // The command line switch used to pass name of the pipe to capture audio on | 112 // The command line switch used to pass name of the pipe to capture audio on |
| 113 // linux. | 113 // linux. |
| 114 const char kAudioPipeSwitchName[] = "audio-pipe-name"; | 114 const char kAudioPipeSwitchName[] = "audio-pipe-name"; |
| 115 |
| 116 // The command line switch used to pass name of the unix domain socket used to |
| 117 // listen for gnubby requests. |
| 118 const char kAuthSocknameSwitchName[] = "ssh-auth-sockname"; |
| 115 #endif // defined(OS_LINUX) | 119 #endif // defined(OS_LINUX) |
| 116 | 120 |
| 117 // The command line switch used by the parent to request the host to signal it | 121 // The command line switch used by the parent to request the host to signal it |
| 118 // when it is successfully started. | 122 // when it is successfully started. |
| 119 const char kSignalParentSwitchName[] = "signal-parent"; | 123 const char kSignalParentSwitchName[] = "signal-parent"; |
| 120 | 124 |
| 121 // Value used for --host-config option to indicate that the path must be read | 125 // Value used for --host-config option to indicate that the path must be read |
| 122 // from stdin. | 126 // from stdin. |
| 123 const char kStdinConfigPath[] = "-"; | 127 const char kStdinConfigPath[] = "-"; |
| 124 | 128 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 bool OnUsernamePolicyUpdate(bool curtain_required, | 226 bool OnUsernamePolicyUpdate(bool curtain_required, |
| 223 bool username_match_required); | 227 bool username_match_required); |
| 224 bool OnNatPolicyUpdate(bool nat_traversal_enabled); | 228 bool OnNatPolicyUpdate(bool nat_traversal_enabled); |
| 225 void OnCurtainPolicyUpdate(bool curtain_required); | 229 void OnCurtainPolicyUpdate(bool curtain_required); |
| 226 bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix); | 230 bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix); |
| 227 bool OnHostTokenUrlPolicyUpdate( | 231 bool OnHostTokenUrlPolicyUpdate( |
| 228 const GURL& token_url, | 232 const GURL& token_url, |
| 229 const GURL& token_validation_url, | 233 const GURL& token_validation_url, |
| 230 const std::string& token_validation_cert_issuer); | 234 const std::string& token_validation_cert_issuer); |
| 231 bool OnPairingPolicyUpdate(bool pairing_enabled); | 235 bool OnPairingPolicyUpdate(bool pairing_enabled); |
| 236 bool OnGnubbyAuthPolicyUpdate(bool enable_gnubby_auth); |
| 232 | 237 |
| 233 void StartHost(); | 238 void StartHost(); |
| 234 | 239 |
| 235 void OnAuthFailed(); | 240 void OnAuthFailed(); |
| 236 | 241 |
| 237 void RestartHost(); | 242 void RestartHost(); |
| 238 | 243 |
| 239 // Stops the host and shuts down the process with the specified |exit_code|. | 244 // Stops the host and shuts down the process with the specified |exit_code|. |
| 240 void ShutdownHost(HostExitCodes exit_code); | 245 void ShutdownHost(HostExitCodes exit_code); |
| 241 | 246 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 std::string serialized_config_; | 284 std::string serialized_config_; |
| 280 std::string host_owner_; | 285 std::string host_owner_; |
| 281 bool use_service_account_; | 286 bool use_service_account_; |
| 282 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; | 287 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; |
| 283 bool allow_nat_traversal_; | 288 bool allow_nat_traversal_; |
| 284 std::string talkgadget_prefix_; | 289 std::string talkgadget_prefix_; |
| 285 bool allow_pairing_; | 290 bool allow_pairing_; |
| 286 | 291 |
| 287 bool curtain_required_; | 292 bool curtain_required_; |
| 288 ThirdPartyAuthConfig third_party_auth_config_; | 293 ThirdPartyAuthConfig third_party_auth_config_; |
| 294 bool enable_gnubby_auth_; |
| 289 | 295 |
| 290 scoped_ptr<OAuthTokenGetter> oauth_token_getter_; | 296 scoped_ptr<OAuthTokenGetter> oauth_token_getter_; |
| 291 scoped_ptr<XmppSignalStrategy> signal_strategy_; | 297 scoped_ptr<XmppSignalStrategy> signal_strategy_; |
| 292 scoped_ptr<SignalingConnector> signaling_connector_; | 298 scoped_ptr<SignalingConnector> signaling_connector_; |
| 293 scoped_ptr<HeartbeatSender> heartbeat_sender_; | 299 scoped_ptr<HeartbeatSender> heartbeat_sender_; |
| 294 scoped_ptr<HostStatusSender> host_status_sender_; | 300 scoped_ptr<HostStatusSender> host_status_sender_; |
| 295 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; | 301 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; |
| 296 scoped_ptr<LogToServer> log_to_server_; | 302 scoped_ptr<LogToServer> log_to_server_; |
| 297 scoped_ptr<HostEventLogger> host_event_logger_; | 303 scoped_ptr<HostEventLogger> host_event_logger_; |
| 298 | 304 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 312 }; | 318 }; |
| 313 | 319 |
| 314 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, | 320 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, |
| 315 int* exit_code_out) | 321 int* exit_code_out) |
| 316 : context_(context.Pass()), | 322 : context_(context.Pass()), |
| 317 state_(HOST_INITIALIZING), | 323 state_(HOST_INITIALIZING), |
| 318 use_service_account_(false), | 324 use_service_account_(false), |
| 319 allow_nat_traversal_(true), | 325 allow_nat_traversal_(true), |
| 320 allow_pairing_(true), | 326 allow_pairing_(true), |
| 321 curtain_required_(false), | 327 curtain_required_(false), |
| 328 enable_gnubby_auth_(false), |
| 322 #if defined(REMOTING_MULTI_PROCESS) | 329 #if defined(REMOTING_MULTI_PROCESS) |
| 323 desktop_session_connector_(NULL), | 330 desktop_session_connector_(NULL), |
| 324 #endif // defined(REMOTING_MULTI_PROCESS) | 331 #endif // defined(REMOTING_MULTI_PROCESS) |
| 325 self_(this), | 332 self_(this), |
| 326 exit_code_out_(exit_code_out), | 333 exit_code_out_(exit_code_out), |
| 327 signal_parent_(false) { | 334 signal_parent_(false) { |
| 328 StartOnUiThread(); | 335 StartOnUiThread(); |
| 329 } | 336 } |
| 330 | 337 |
| 331 HostProcess::~HostProcess() { | 338 HostProcess::~HostProcess() { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 | 631 |
| 625 #if defined(OS_LINUX) | 632 #if defined(OS_LINUX) |
| 626 // If an audio pipe is specific on the command-line then initialize | 633 // If an audio pipe is specific on the command-line then initialize |
| 627 // AudioCapturerLinux to capture from it. | 634 // AudioCapturerLinux to capture from it. |
| 628 base::FilePath audio_pipe_name = CommandLine::ForCurrentProcess()-> | 635 base::FilePath audio_pipe_name = CommandLine::ForCurrentProcess()-> |
| 629 GetSwitchValuePath(kAudioPipeSwitchName); | 636 GetSwitchValuePath(kAudioPipeSwitchName); |
| 630 if (!audio_pipe_name.empty()) { | 637 if (!audio_pipe_name.empty()) { |
| 631 remoting::AudioCapturerLinux::InitializePipeReader( | 638 remoting::AudioCapturerLinux::InitializePipeReader( |
| 632 context_->audio_task_runner(), audio_pipe_name); | 639 context_->audio_task_runner(), audio_pipe_name); |
| 633 } | 640 } |
| 641 |
| 642 base::FilePath gnubby_socket_name = CommandLine::ForCurrentProcess()-> |
| 643 GetSwitchValuePath(kAuthSocknameSwitchName); |
| 644 if (!gnubby_socket_name.empty()) |
| 645 remoting::GnubbyAuthHandler::SetGnubbySocketName(gnubby_socket_name); |
| 634 #endif // defined(OS_LINUX) | 646 #endif // defined(OS_LINUX) |
| 635 | 647 |
| 636 // Create a desktop environment factory appropriate to the build type & | 648 // Create a desktop environment factory appropriate to the build type & |
| 637 // platform. | 649 // platform. |
| 638 #if defined(OS_WIN) | 650 #if defined(OS_WIN) |
| 639 IpcDesktopEnvironmentFactory* desktop_environment_factory = | 651 IpcDesktopEnvironmentFactory* desktop_environment_factory = |
| 640 new IpcDesktopEnvironmentFactory( | 652 new IpcDesktopEnvironmentFactory( |
| 641 context_->audio_task_runner(), | 653 context_->audio_task_runner(), |
| 642 context_->network_task_runner(), | 654 context_->network_task_runner(), |
| 643 context_->video_capture_task_runner(), | 655 context_->video_capture_task_runner(), |
| 644 context_->network_task_runner(), | 656 context_->network_task_runner(), |
| 645 daemon_channel_.get()); | 657 daemon_channel_.get()); |
| 646 desktop_session_connector_ = desktop_environment_factory; | 658 desktop_session_connector_ = desktop_environment_factory; |
| 647 #else // !defined(OS_WIN) | 659 #else // !defined(OS_WIN) |
| 648 DesktopEnvironmentFactory* desktop_environment_factory = | 660 DesktopEnvironmentFactory* desktop_environment_factory = |
| 649 new Me2MeDesktopEnvironmentFactory( | 661 new Me2MeDesktopEnvironmentFactory( |
| 650 context_->network_task_runner(), | 662 context_->network_task_runner(), |
| 651 context_->input_task_runner(), | 663 context_->input_task_runner(), |
| 652 context_->ui_task_runner()); | 664 context_->ui_task_runner()); |
| 653 #endif // !defined(OS_WIN) | 665 #endif // !defined(OS_WIN) |
| 654 | 666 |
| 655 desktop_environment_factory_.reset(desktop_environment_factory); | 667 desktop_environment_factory_.reset(desktop_environment_factory); |
| 668 desktop_environment_factory_->SetEnableGnubbyAuth(enable_gnubby_auth_); |
| 656 | 669 |
| 657 context_->network_task_runner()->PostTask( | 670 context_->network_task_runner()->PostTask( |
| 658 FROM_HERE, | 671 FROM_HERE, |
| 659 base::Bind(&HostProcess::StartOnNetworkThread, this)); | 672 base::Bind(&HostProcess::StartOnNetworkThread, this)); |
| 660 } | 673 } |
| 661 | 674 |
| 662 void HostProcess::ShutdownOnUiThread() { | 675 void HostProcess::ShutdownOnUiThread() { |
| 663 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); | 676 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); |
| 664 | 677 |
| 665 // Tear down resources that need to be torn down on the UI thread. | 678 // Tear down resources that need to be torn down on the UI thread. |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 &token_validation_cert_issuer)) { | 853 &token_validation_cert_issuer)) { |
| 841 restart_required |= OnHostTokenUrlPolicyUpdate( | 854 restart_required |= OnHostTokenUrlPolicyUpdate( |
| 842 GURL(token_url_string), GURL(token_validation_url_string), | 855 GURL(token_url_string), GURL(token_validation_url_string), |
| 843 token_validation_cert_issuer); | 856 token_validation_cert_issuer); |
| 844 } | 857 } |
| 845 if (policies->GetBoolean( | 858 if (policies->GetBoolean( |
| 846 policy_hack::PolicyWatcher::kHostAllowClientPairing, | 859 policy_hack::PolicyWatcher::kHostAllowClientPairing, |
| 847 &bool_value)) { | 860 &bool_value)) { |
| 848 restart_required |= OnPairingPolicyUpdate(bool_value); | 861 restart_required |= OnPairingPolicyUpdate(bool_value); |
| 849 } | 862 } |
| 863 if (policies->GetBoolean( |
| 864 policy_hack::PolicyWatcher::kHostAllowGnubbyAuthPolicyName, |
| 865 &bool_value)) |
| 866 restart_required |= OnGnubbyAuthPolicyUpdate(bool_value); |
| 850 | 867 |
| 851 if (state_ == HOST_INITIALIZING) { | 868 if (state_ == HOST_INITIALIZING) { |
| 852 StartHost(); | 869 StartHost(); |
| 853 } else if (state_ == HOST_STARTED && restart_required) { | 870 } else if (state_ == HOST_STARTED && restart_required) { |
| 854 RestartHost(); | 871 RestartHost(); |
| 855 } | 872 } |
| 856 } | 873 } |
| 857 | 874 |
| 858 bool HostProcess::OnHostDomainPolicyUpdate(const std::string& host_domain) { | 875 bool HostProcess::OnHostDomainPolicyUpdate(const std::string& host_domain) { |
| 859 // Returns true if the host has to be restarted after this policy update. | 876 // Returns true if the host has to be restarted after this policy update. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 return false; | 1022 return false; |
| 1006 | 1023 |
| 1007 if (allow_pairing) | 1024 if (allow_pairing) |
| 1008 HOST_LOG << "Policy enables client pairing."; | 1025 HOST_LOG << "Policy enables client pairing."; |
| 1009 else | 1026 else |
| 1010 HOST_LOG << "Policy disables client pairing."; | 1027 HOST_LOG << "Policy disables client pairing."; |
| 1011 allow_pairing_ = allow_pairing; | 1028 allow_pairing_ = allow_pairing; |
| 1012 return true; | 1029 return true; |
| 1013 } | 1030 } |
| 1014 | 1031 |
| 1032 bool HostProcess::OnGnubbyAuthPolicyUpdate(bool enable_gnubby_auth) { |
| 1033 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| 1034 |
| 1035 if (enable_gnubby_auth_ == enable_gnubby_auth) |
| 1036 return false; |
| 1037 |
| 1038 if (enable_gnubby_auth) { |
| 1039 HOST_LOG << "Policy enables gnubby auth."; |
| 1040 } else { |
| 1041 HOST_LOG << "Policy disables gnubby auth."; |
| 1042 } |
| 1043 enable_gnubby_auth_ = enable_gnubby_auth; |
| 1044 |
| 1045 if (desktop_environment_factory_) |
| 1046 desktop_environment_factory_->SetEnableGnubbyAuth(enable_gnubby_auth); |
| 1047 |
| 1048 return true; |
| 1049 } |
| 1050 |
| 1015 void HostProcess::StartHost() { | 1051 void HostProcess::StartHost() { |
| 1016 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 1052 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| 1017 DCHECK(!host_); | 1053 DCHECK(!host_); |
| 1018 DCHECK(!signal_strategy_.get()); | 1054 DCHECK(!signal_strategy_.get()); |
| 1019 DCHECK(state_ == HOST_INITIALIZING || state_ == HOST_STOPPING_TO_RESTART || | 1055 DCHECK(state_ == HOST_INITIALIZING || state_ == HOST_STOPPING_TO_RESTART || |
| 1020 state_ == HOST_STOPPED) << state_; | 1056 state_ == HOST_STOPPED) << state_; |
| 1021 state_ = HOST_STARTED; | 1057 state_ = HOST_STARTED; |
| 1022 | 1058 |
| 1023 signal_strategy_.reset( | 1059 signal_strategy_.reset( |
| 1024 new XmppSignalStrategy(net::ClientSocketFactory::GetDefaultFactory(), | 1060 new XmppSignalStrategy(net::ClientSocketFactory::GetDefaultFactory(), |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 return exit_code; | 1277 return exit_code; |
| 1242 } | 1278 } |
| 1243 | 1279 |
| 1244 } // namespace remoting | 1280 } // namespace remoting |
| 1245 | 1281 |
| 1246 #if !defined(OS_WIN) | 1282 #if !defined(OS_WIN) |
| 1247 int main(int argc, char** argv) { | 1283 int main(int argc, char** argv) { |
| 1248 return remoting::HostMain(argc, argv); | 1284 return remoting::HostMain(argc, argv); |
| 1249 } | 1285 } |
| 1250 #endif // !defined(OS_WIN) | 1286 #endif // !defined(OS_WIN) |
| OLD | NEW |