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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 std::string xmpp_login_; | 236 std::string xmpp_login_; |
237 std::string xmpp_auth_token_; | 237 std::string xmpp_auth_token_; |
238 std::string xmpp_auth_service_; | 238 std::string xmpp_auth_service_; |
239 | 239 |
240 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; | 240 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; |
241 bool allow_nat_traversal_; | 241 bool allow_nat_traversal_; |
242 std::string talkgadget_prefix_; | 242 std::string talkgadget_prefix_; |
243 | 243 |
244 scoped_ptr<CurtainMode> curtain_; | 244 scoped_ptr<CurtainMode> curtain_; |
245 scoped_ptr<CurtainingHostObserver> curtaining_host_observer_; | 245 scoped_ptr<CurtainingHostObserver> curtaining_host_observer_; |
| 246 bool curtain_required_; |
246 | 247 |
247 bool restarting_; | 248 bool restarting_; |
248 bool shutting_down_; | 249 bool shutting_down_; |
249 | 250 |
250 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; | 251 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; |
251 scoped_ptr<DesktopResizer> desktop_resizer_; | 252 scoped_ptr<DesktopResizer> desktop_resizer_; |
252 scoped_ptr<ResizingHostObserver> resizing_host_observer_; | 253 scoped_ptr<ResizingHostObserver> resizing_host_observer_; |
253 scoped_ptr<XmppSignalStrategy> signal_strategy_; | 254 scoped_ptr<XmppSignalStrategy> signal_strategy_; |
254 scoped_ptr<SignalingConnector> signaling_connector_; | 255 scoped_ptr<SignalingConnector> signaling_connector_; |
255 scoped_ptr<HeartbeatSender> heartbeat_sender_; | 256 scoped_ptr<HeartbeatSender> heartbeat_sender_; |
256 scoped_ptr<LogToServer> log_to_server_; | 257 scoped_ptr<LogToServer> log_to_server_; |
257 scoped_ptr<HostEventLogger> host_event_logger_; | 258 scoped_ptr<HostEventLogger> host_event_logger_; |
258 | 259 |
259 scoped_ptr<HostUserInterface> host_user_interface_; | 260 scoped_ptr<HostUserInterface> host_user_interface_; |
260 | 261 |
261 scoped_refptr<ChromotingHost> host_; | 262 scoped_refptr<ChromotingHost> host_; |
262 | 263 |
263 #if defined(REMOTING_MULTI_PROCESS) | 264 #if defined(REMOTING_MULTI_PROCESS) |
264 DesktopSessionConnector* desktop_session_connector_; | 265 DesktopSessionConnector* desktop_session_connector_; |
265 #endif // defined(REMOTING_MULTI_PROCESS) | 266 #endif // defined(REMOTING_MULTI_PROCESS) |
266 | 267 |
267 int exit_code_; | 268 int exit_code_; |
268 }; | 269 }; |
269 | 270 |
270 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context) | 271 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context) |
271 : context_(context.Pass()), | 272 : context_(context.Pass()), |
272 allow_nat_traversal_(true), | 273 allow_nat_traversal_(true), |
| 274 curtain_required_(false), |
273 restarting_(false), | 275 restarting_(false), |
274 shutting_down_(false), | 276 shutting_down_(false), |
275 desktop_resizer_(DesktopResizer::Create()), | 277 desktop_resizer_(DesktopResizer::Create()), |
276 #if defined(REMOTING_MULTI_PROCESS) | 278 #if defined(REMOTING_MULTI_PROCESS) |
277 desktop_session_connector_(NULL), | 279 desktop_session_connector_(NULL), |
278 #endif // defined(REMOTING_MULTI_PROCESS) | 280 #endif // defined(REMOTING_MULTI_PROCESS) |
279 exit_code_(kSuccessExitCode) { | 281 exit_code_(kSuccessExitCode) { |
280 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); | 282 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
281 curtain_ = CurtainMode::Create( | 283 curtain_ = CurtainMode::Create( |
282 base::Bind(&HostProcess::OnDisconnectRequested, | 284 base::Bind(&HostProcess::OnDisconnectRequested, |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 StartHost(); | 668 StartHost(); |
667 } else if (restart_required) { | 669 } else if (restart_required) { |
668 RestartHost(); | 670 RestartHost(); |
669 } | 671 } |
670 } | 672 } |
671 | 673 |
672 bool HostProcess::OnHostDomainPolicyUpdate(const std::string& host_domain) { | 674 bool HostProcess::OnHostDomainPolicyUpdate(const std::string& host_domain) { |
673 // Returns true if the host has to be restarted after this policy update. | 675 // Returns true if the host has to be restarted after this policy update. |
674 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 676 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
675 | 677 |
| 678 LOG(INFO) << "Policy sets host domain: " << host_domain; |
| 679 |
676 if (!host_domain.empty() && | 680 if (!host_domain.empty() && |
677 !EndsWith(xmpp_login_, std::string("@") + host_domain, false)) { | 681 !EndsWith(xmpp_login_, std::string("@") + host_domain, false)) { |
678 Shutdown(kInvalidHostDomainExitCode); | 682 Shutdown(kInvalidHostDomainExitCode); |
679 } | 683 } |
680 return false; | 684 return false; |
681 } | 685 } |
682 | 686 |
683 bool HostProcess::OnUsernamePolicyUpdate(bool host_username_match_required) { | 687 bool HostProcess::OnUsernamePolicyUpdate(bool host_username_match_required) { |
684 // Returns false: never restart the host after this policy update. | 688 // Returns false: never restart the host after this policy update. |
685 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 689 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
686 | 690 |
687 if (host_username_match_required) { | 691 if (host_username_match_required) { |
| 692 LOG(INFO) << "Policy requires host username match."; |
688 if (!CanGetUsername() || | 693 if (!CanGetUsername() || |
689 !StartsWithASCII(xmpp_login_, GetUsername() + std::string("@"), | 694 !StartsWithASCII(xmpp_login_, GetUsername() + std::string("@"), |
690 false)) { | 695 false)) { |
691 Shutdown(kUsernameMismatchExitCode); | 696 Shutdown(kUsernameMismatchExitCode); |
692 } | 697 } |
| 698 } else { |
| 699 LOG(INFO) << "Policy does not require host username match."; |
693 } | 700 } |
| 701 |
694 return false; | 702 return false; |
695 } | 703 } |
696 | 704 |
697 bool HostProcess::OnNatPolicyUpdate(bool nat_traversal_enabled) { | 705 bool HostProcess::OnNatPolicyUpdate(bool nat_traversal_enabled) { |
698 // Returns true if the host has to be restarted after this policy update. | 706 // Returns true if the host has to be restarted after this policy update. |
699 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 707 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
700 | 708 |
701 if (allow_nat_traversal_ != nat_traversal_enabled) { | 709 if (allow_nat_traversal_ != nat_traversal_enabled) { |
| 710 if (nat_traversal_enabled) |
| 711 LOG(INFO) << "Policy enables NAT traversal."; |
| 712 else |
| 713 LOG(INFO) << "Policy disables NAT traversal."; |
702 allow_nat_traversal_ = nat_traversal_enabled; | 714 allow_nat_traversal_ = nat_traversal_enabled; |
703 LOG(INFO) << "Updated NAT policy."; | |
704 return true; | 715 return true; |
705 } | 716 } |
706 return false; | 717 return false; |
707 } | 718 } |
708 | 719 |
709 bool HostProcess::OnCurtainPolicyUpdate(bool curtain_required) { | 720 bool HostProcess::OnCurtainPolicyUpdate(bool curtain_required) { |
710 // Returns true if the host has to be restarted after this policy update. | 721 // Returns true if the host has to be restarted after this policy update. |
711 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 722 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
712 | 723 |
713 #if defined(OS_MACOSX) | 724 #if defined(OS_MACOSX) |
714 if (curtain_required) { | 725 if (curtain_required) { |
715 // If curtain mode is required, then we can't currently support remoting | 726 // When curtain mode is in effect on Mac, the host process runs in the |
716 // the login screen. This is because we don't curtain the login screen | 727 // user's switched-out session, but launchd will also run an instance at |
717 // and the current daemon architecture means that the connction is closed | 728 // the console login screen. Even if no user is currently logged-on, we |
718 // immediately after login, leaving the host system uncurtained. | 729 // can't support remote-access to the login screen because the current host |
| 730 // process model disconnects the client during login, which would leave |
| 731 // the logged in session un-curtained on the console until they reconnect. |
719 // | 732 // |
720 // TODO(jamiewalch): Fix this once we have implemented the multi-process | 733 // TODO(jamiewalch): Fix this once we have implemented the multi-process |
721 // daemon architecture (crbug.com/134894) | 734 // daemon architecture (crbug.com/134894) |
722 if (getuid() == 0) { | 735 if (getuid() == 0) { |
723 Shutdown(kLoginScreenNotSupportedExitCode); | 736 Shutdown(kLoginScreenNotSupportedExitCode); |
724 return false; | 737 return false; |
725 } | 738 } |
726 } | 739 } |
727 #endif | 740 #endif |
728 if (curtain_->required() != curtain_required) { | 741 |
729 LOG(INFO) << "Updated curtain policy."; | 742 if (curtain_required_ != curtain_required) { |
730 curtain_->set_required(curtain_required); | 743 if (curtain_required) |
| 744 LOG(ERROR) << "Policy requires curtain-mode."; |
| 745 else |
| 746 LOG(ERROR) << "Policy does not require curtain-mode."; |
| 747 curtain_required_ = curtain_required; |
| 748 curtaining_host_observer_->SetEnableCurtaining(curtain_required_); |
731 return true; | 749 return true; |
732 } | 750 } |
733 return false; | 751 return false; |
734 } | 752 } |
735 | 753 |
736 bool HostProcess::OnHostTalkGadgetPrefixPolicyUpdate( | 754 bool HostProcess::OnHostTalkGadgetPrefixPolicyUpdate( |
737 const std::string& talkgadget_prefix) { | 755 const std::string& talkgadget_prefix) { |
738 // Returns true if the host has to be restarted after this policy update. | 756 // Returns true if the host has to be restarted after this policy update. |
739 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 757 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
740 | 758 |
741 if (talkgadget_prefix != talkgadget_prefix_) { | 759 if (talkgadget_prefix != talkgadget_prefix_) { |
742 LOG(INFO) << "Updated talkgadget policy."; | 760 LOG(INFO) << "Policy sets talkgadget prefix: " << talkgadget_prefix; |
743 talkgadget_prefix_ = talkgadget_prefix; | 761 talkgadget_prefix_ = talkgadget_prefix; |
744 return true; | 762 return true; |
745 } | 763 } |
746 return false; | 764 return false; |
747 } | 765 } |
748 | 766 |
749 void HostProcess::StartHost() { | 767 void HostProcess::StartHost() { |
750 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 768 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
751 DCHECK(!host_); | 769 DCHECK(!host_); |
752 DCHECK(!signal_strategy_.get()); | 770 DCHECK(!signal_strategy_.get()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 host_event_logger_ = HostEventLogger::Create(host_, kApplicationName); | 826 host_event_logger_ = HostEventLogger::Create(host_, kApplicationName); |
809 | 827 |
810 #if defined(OS_LINUX) | 828 #if defined(OS_LINUX) |
811 // Desktop resizing is implemented on all three platforms, but may not be | 829 // Desktop resizing is implemented on all three platforms, but may not be |
812 // the right thing to do for non-virtual desktops. Disable it until we can | 830 // the right thing to do for non-virtual desktops. Disable it until we can |
813 // implement a configuration UI. | 831 // implement a configuration UI. |
814 resizing_host_observer_.reset( | 832 resizing_host_observer_.reset( |
815 new ResizingHostObserver(desktop_resizer_.get(), host_)); | 833 new ResizingHostObserver(desktop_resizer_.get(), host_)); |
816 #endif | 834 #endif |
817 | 835 |
818 // Curtain mode is currently broken on Mac (the only supported platform), | 836 // Create a host observer to enable/disable curtain mode as clients connect |
819 // so it's disabled until we've had time to fully investigate. | 837 // and disconnect. |
820 // curtaining_host_observer_.reset(new CurtainingHostObserver( | 838 curtaining_host_observer_.reset(new CurtainingHostObserver( |
821 // curtain_.get(), host_)); | 839 curtain_.get(), host_)); |
| 840 curtaining_host_observer_->SetEnableCurtaining(curtain_required_); |
822 | 841 |
823 if (host_user_interface_.get()) { | 842 if (host_user_interface_.get()) { |
824 host_user_interface_->Start( | 843 host_user_interface_->Start( |
825 host_, base::Bind(&HostProcess::OnDisconnectRequested, | 844 host_, base::Bind(&HostProcess::OnDisconnectRequested, |
826 base::Unretained(this))); | 845 base::Unretained(this))); |
827 } | 846 } |
828 | 847 |
829 host_->Start(xmpp_login_); | 848 host_->Start(xmpp_login_); |
830 | 849 |
831 CreateAuthenticatorFactory(); | 850 CreateAuthenticatorFactory(); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 user32.GetFunctionPointer("SetProcessDPIAware")); | 1037 user32.GetFunctionPointer("SetProcessDPIAware")); |
1019 set_process_dpi_aware(); | 1038 set_process_dpi_aware(); |
1020 } | 1039 } |
1021 | 1040 |
1022 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting | 1041 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting |
1023 // the command line from GetCommandLineW(), so we can safely pass NULL here. | 1042 // the command line from GetCommandLineW(), so we can safely pass NULL here. |
1024 return main(0, NULL); | 1043 return main(0, NULL); |
1025 } | 1044 } |
1026 | 1045 |
1027 #endif // defined(OS_WIN) | 1046 #endif // defined(OS_WIN) |
OLD | NEW |