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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 #include "ui/gfx/gtk_util.h" | 99 #include "ui/gfx/gtk_util.h" |
100 #endif // defined(TOOLKIT_GTK) | 100 #endif // defined(TOOLKIT_GTK) |
101 | 101 |
102 // This is used for tagging system event logs. | 102 // This is used for tagging system event logs. |
103 const char kApplicationName[] = "chromoting"; | 103 const char kApplicationName[] = "chromoting"; |
104 | 104 |
105 #if defined(OS_LINUX) | 105 #if defined(OS_LINUX) |
106 // The command line switch used to pass name of the pipe to capture audio on | 106 // The command line switch used to pass name of the pipe to capture audio on |
107 // linux. | 107 // linux. |
108 const char kAudioPipeSwitchName[] = "audio-pipe-name"; | 108 const char kAudioPipeSwitchName[] = "audio-pipe-name"; |
109 | |
110 // The command line switch used to pass name of the unix domain socket used to | |
111 // listen for gnubby requests. | |
112 const char kAuthSocknameSwitchName[] = "ssh-auth-sockname"; | |
Sergey Ulanov
2014/02/09 22:29:54
can it be called gnubby-auth-sockname (because it
psj
2014/02/10 22:57:22
I proposed a name with gnubby, but Wez preferred t
| |
109 #endif // defined(OS_LINUX) | 113 #endif // defined(OS_LINUX) |
110 | 114 |
111 // The command line switch used by the parent to request the host to signal it | 115 // The command line switch used by the parent to request the host to signal it |
112 // when it is successfully started. | 116 // when it is successfully started. |
113 const char kSignalParentSwitchName[] = "signal-parent"; | 117 const char kSignalParentSwitchName[] = "signal-parent"; |
114 | 118 |
115 // Value used for --host-config option to indicate that the path must be read | 119 // Value used for --host-config option to indicate that the path must be read |
116 // from stdin. | 120 // from stdin. |
117 const char kStdinConfigPath[] = "-"; | 121 const char kStdinConfigPath[] = "-"; |
118 | 122 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 bool OnUsernamePolicyUpdate(bool curtain_required, | 213 bool OnUsernamePolicyUpdate(bool curtain_required, |
210 bool username_match_required); | 214 bool username_match_required); |
211 bool OnNatPolicyUpdate(bool nat_traversal_enabled); | 215 bool OnNatPolicyUpdate(bool nat_traversal_enabled); |
212 void OnCurtainPolicyUpdate(bool curtain_required); | 216 void OnCurtainPolicyUpdate(bool curtain_required); |
213 bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix); | 217 bool OnHostTalkGadgetPrefixPolicyUpdate(const std::string& talkgadget_prefix); |
214 bool OnHostTokenUrlPolicyUpdate( | 218 bool OnHostTokenUrlPolicyUpdate( |
215 const GURL& token_url, | 219 const GURL& token_url, |
216 const GURL& token_validation_url, | 220 const GURL& token_validation_url, |
217 const std::string& token_validation_cert_issuer); | 221 const std::string& token_validation_cert_issuer); |
218 bool OnPairingPolicyUpdate(bool pairing_enabled); | 222 bool OnPairingPolicyUpdate(bool pairing_enabled); |
223 bool OnGnubbyAuthPolicyUpdate(bool enable_gnubby_auth); | |
219 | 224 |
220 void StartHost(); | 225 void StartHost(); |
221 | 226 |
222 void OnAuthFailed(); | 227 void OnAuthFailed(); |
223 | 228 |
224 void RestartHost(); | 229 void RestartHost(); |
225 | 230 |
226 // Stops the host and shuts down the process with the specified |exit_code|. | 231 // Stops the host and shuts down the process with the specified |exit_code|. |
227 void ShutdownHost(HostExitCodes exit_code); | 232 void ShutdownHost(HostExitCodes exit_code); |
228 | 233 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 std::string serialized_config_; | 271 std::string serialized_config_; |
267 std::string host_owner_; | 272 std::string host_owner_; |
268 bool use_service_account_; | 273 bool use_service_account_; |
269 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; | 274 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; |
270 bool allow_nat_traversal_; | 275 bool allow_nat_traversal_; |
271 std::string talkgadget_prefix_; | 276 std::string talkgadget_prefix_; |
272 bool allow_pairing_; | 277 bool allow_pairing_; |
273 | 278 |
274 bool curtain_required_; | 279 bool curtain_required_; |
275 ThirdPartyAuthConfig third_party_auth_config_; | 280 ThirdPartyAuthConfig third_party_auth_config_; |
281 bool enable_gnubby_auth_; | |
276 | 282 |
277 scoped_ptr<XmppSignalStrategy> signal_strategy_; | 283 scoped_ptr<XmppSignalStrategy> signal_strategy_; |
278 scoped_ptr<SignalingConnector> signaling_connector_; | 284 scoped_ptr<SignalingConnector> signaling_connector_; |
279 scoped_ptr<HeartbeatSender> heartbeat_sender_; | 285 scoped_ptr<HeartbeatSender> heartbeat_sender_; |
280 scoped_ptr<HostStatusSender> host_status_sender_; | 286 scoped_ptr<HostStatusSender> host_status_sender_; |
281 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; | 287 scoped_ptr<HostChangeNotificationListener> host_change_notification_listener_; |
282 scoped_ptr<LogToServer> log_to_server_; | 288 scoped_ptr<LogToServer> log_to_server_; |
283 scoped_ptr<HostEventLogger> host_event_logger_; | 289 scoped_ptr<HostEventLogger> host_event_logger_; |
284 | 290 |
285 scoped_ptr<ChromotingHost> host_; | 291 scoped_ptr<ChromotingHost> host_; |
(...skipping 10 matching lines...) Expand all Loading... | |
296 }; | 302 }; |
297 | 303 |
298 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, | 304 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, |
299 int* exit_code_out) | 305 int* exit_code_out) |
300 : context_(context.Pass()), | 306 : context_(context.Pass()), |
301 state_(HOST_INITIALIZING), | 307 state_(HOST_INITIALIZING), |
302 use_service_account_(false), | 308 use_service_account_(false), |
303 allow_nat_traversal_(true), | 309 allow_nat_traversal_(true), |
304 allow_pairing_(true), | 310 allow_pairing_(true), |
305 curtain_required_(false), | 311 curtain_required_(false), |
312 enable_gnubby_auth_(false), | |
306 #if defined(REMOTING_MULTI_PROCESS) | 313 #if defined(REMOTING_MULTI_PROCESS) |
307 desktop_session_connector_(NULL), | 314 desktop_session_connector_(NULL), |
308 #endif // defined(REMOTING_MULTI_PROCESS) | 315 #endif // defined(REMOTING_MULTI_PROCESS) |
309 self_(this), | 316 self_(this), |
310 exit_code_out_(exit_code_out), | 317 exit_code_out_(exit_code_out), |
311 signal_parent_(false) { | 318 signal_parent_(false) { |
312 StartOnUiThread(); | 319 StartOnUiThread(); |
313 } | 320 } |
314 | 321 |
315 HostProcess::~HostProcess() { | 322 HostProcess::~HostProcess() { |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
600 | 607 |
601 #if defined(OS_LINUX) | 608 #if defined(OS_LINUX) |
602 // If an audio pipe is specific on the command-line then initialize | 609 // If an audio pipe is specific on the command-line then initialize |
603 // AudioCapturerLinux to capture from it. | 610 // AudioCapturerLinux to capture from it. |
604 base::FilePath audio_pipe_name = CommandLine::ForCurrentProcess()-> | 611 base::FilePath audio_pipe_name = CommandLine::ForCurrentProcess()-> |
605 GetSwitchValuePath(kAudioPipeSwitchName); | 612 GetSwitchValuePath(kAudioPipeSwitchName); |
606 if (!audio_pipe_name.empty()) { | 613 if (!audio_pipe_name.empty()) { |
607 remoting::AudioCapturerLinux::InitializePipeReader( | 614 remoting::AudioCapturerLinux::InitializePipeReader( |
608 context_->audio_task_runner(), audio_pipe_name); | 615 context_->audio_task_runner(), audio_pipe_name); |
609 } | 616 } |
617 | |
618 base::FilePath gnubby_socket_name_name = CommandLine::ForCurrentProcess()-> | |
619 GetSwitchValuePath(kAuthSocknameSwitchName); | |
620 if (!gnubby_socket_name_name.empty()) { | |
621 remoting::GnubbyAuthHandler::SetGnubbySocketName(gnubby_socket_name_name); | |
622 } | |
610 #endif // defined(OS_LINUX) | 623 #endif // defined(OS_LINUX) |
611 | 624 |
612 // Create a desktop environment factory appropriate to the build type & | 625 // Create a desktop environment factory appropriate to the build type & |
613 // platform. | 626 // platform. |
614 #if defined(OS_WIN) | 627 #if defined(OS_WIN) |
615 IpcDesktopEnvironmentFactory* desktop_environment_factory = | 628 IpcDesktopEnvironmentFactory* desktop_environment_factory = |
616 new IpcDesktopEnvironmentFactory( | 629 new IpcDesktopEnvironmentFactory( |
617 context_->audio_task_runner(), | 630 context_->audio_task_runner(), |
618 context_->network_task_runner(), | 631 context_->network_task_runner(), |
619 context_->video_capture_task_runner(), | 632 context_->video_capture_task_runner(), |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
793 &token_validation_cert_issuer)) { | 806 &token_validation_cert_issuer)) { |
794 restart_required |= OnHostTokenUrlPolicyUpdate( | 807 restart_required |= OnHostTokenUrlPolicyUpdate( |
795 GURL(token_url_string), GURL(token_validation_url_string), | 808 GURL(token_url_string), GURL(token_validation_url_string), |
796 token_validation_cert_issuer); | 809 token_validation_cert_issuer); |
797 } | 810 } |
798 if (policies->GetBoolean( | 811 if (policies->GetBoolean( |
799 policy_hack::PolicyWatcher::kHostAllowClientPairing, | 812 policy_hack::PolicyWatcher::kHostAllowClientPairing, |
800 &bool_value)) { | 813 &bool_value)) { |
801 restart_required |= OnPairingPolicyUpdate(bool_value); | 814 restart_required |= OnPairingPolicyUpdate(bool_value); |
802 } | 815 } |
816 if (policies->GetBoolean( | |
817 policy_hack::PolicyWatcher::kHostAllowGnubbyAuthPolicyName, | |
818 &bool_value)) { | |
819 restart_required |= OnGnubbyAuthPolicyUpdate(bool_value); | |
820 } | |
803 | 821 |
804 if (state_ == HOST_INITIALIZING) { | 822 if (state_ == HOST_INITIALIZING) { |
805 StartHost(); | 823 StartHost(); |
806 } else if (state_ == HOST_STARTED && restart_required) { | 824 } else if (state_ == HOST_STARTED && restart_required) { |
807 RestartHost(); | 825 RestartHost(); |
808 } | 826 } |
809 } | 827 } |
810 | 828 |
811 bool HostProcess::OnHostDomainPolicyUpdate(const std::string& host_domain) { | 829 bool HostProcess::OnHostDomainPolicyUpdate(const std::string& host_domain) { |
812 // Returns true if the host has to be restarted after this policy update. | 830 // 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... | |
958 return false; | 976 return false; |
959 | 977 |
960 if (allow_pairing) | 978 if (allow_pairing) |
961 HOST_LOG << "Policy enables client pairing."; | 979 HOST_LOG << "Policy enables client pairing."; |
962 else | 980 else |
963 HOST_LOG << "Policy disables client pairing."; | 981 HOST_LOG << "Policy disables client pairing."; |
964 allow_pairing_ = allow_pairing; | 982 allow_pairing_ = allow_pairing; |
965 return true; | 983 return true; |
966 } | 984 } |
967 | 985 |
986 bool HostProcess::OnGnubbyAuthPolicyUpdate(bool enable_gnubby_auth) { | |
987 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | |
988 | |
989 if (enable_gnubby_auth_ == enable_gnubby_auth) | |
990 return false; | |
991 | |
992 if (enable_gnubby_auth) { | |
993 HOST_LOG << "Policy enables gnubby auth."; | |
994 } else { | |
995 HOST_LOG << "Policy disables gnubby auth."; | |
996 } | |
997 enable_gnubby_auth_ = enable_gnubby_auth; | |
998 | |
999 return true; | |
1000 } | |
1001 | |
968 void HostProcess::StartHost() { | 1002 void HostProcess::StartHost() { |
969 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 1003 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
970 DCHECK(!host_); | 1004 DCHECK(!host_); |
971 DCHECK(!signal_strategy_.get()); | 1005 DCHECK(!signal_strategy_.get()); |
972 DCHECK(state_ == HOST_INITIALIZING || state_ == HOST_STOPPING_TO_RESTART || | 1006 DCHECK(state_ == HOST_INITIALIZING || state_ == HOST_STOPPING_TO_RESTART || |
973 state_ == HOST_STOPPED) << state_; | 1007 state_ == HOST_STOPPED) << state_; |
974 state_ = HOST_STARTED; | 1008 state_ = HOST_STARTED; |
975 | 1009 |
976 signal_strategy_.reset( | 1010 signal_strategy_.reset( |
977 new XmppSignalStrategy(net::ClientSocketFactory::GetDefaultFactory(), | 1011 new XmppSignalStrategy(net::ClientSocketFactory::GetDefaultFactory(), |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1042 // Set up repoting the host status notifications. | 1076 // Set up repoting the host status notifications. |
1043 #if defined(REMOTING_MULTI_PROCESS) | 1077 #if defined(REMOTING_MULTI_PROCESS) |
1044 host_event_logger_.reset( | 1078 host_event_logger_.reset( |
1045 new IpcHostEventLogger(host_->AsWeakPtr(), daemon_channel_.get())); | 1079 new IpcHostEventLogger(host_->AsWeakPtr(), daemon_channel_.get())); |
1046 #else // !defined(REMOTING_MULTI_PROCESS) | 1080 #else // !defined(REMOTING_MULTI_PROCESS) |
1047 host_event_logger_ = | 1081 host_event_logger_ = |
1048 HostEventLogger::Create(host_->AsWeakPtr(), kApplicationName); | 1082 HostEventLogger::Create(host_->AsWeakPtr(), kApplicationName); |
1049 #endif // !defined(REMOTING_MULTI_PROCESS) | 1083 #endif // !defined(REMOTING_MULTI_PROCESS) |
1050 | 1084 |
1051 host_->SetEnableCurtaining(curtain_required_); | 1085 host_->SetEnableCurtaining(curtain_required_); |
1086 host_->SetEnableGnubbyAuth(enable_gnubby_auth_); | |
1052 host_->Start(host_owner_); | 1087 host_->Start(host_owner_); |
1053 | 1088 |
1054 CreateAuthenticatorFactory(); | 1089 CreateAuthenticatorFactory(); |
1055 } | 1090 } |
1056 | 1091 |
1057 void HostProcess::OnAuthFailed() { | 1092 void HostProcess::OnAuthFailed() { |
1058 ShutdownHost(kInvalidOauthCredentialsExitCode); | 1093 ShutdownHost(kInvalidOauthCredentialsExitCode); |
1059 } | 1094 } |
1060 | 1095 |
1061 void HostProcess::RestartHost() { | 1096 void HostProcess::RestartHost() { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1189 return exit_code; | 1224 return exit_code; |
1190 } | 1225 } |
1191 | 1226 |
1192 } // namespace remoting | 1227 } // namespace remoting |
1193 | 1228 |
1194 #if !defined(OS_WIN) | 1229 #if !defined(OS_WIN) |
1195 int main(int argc, char** argv) { | 1230 int main(int argc, char** argv) { |
1196 return remoting::HostMain(argc, argv); | 1231 return remoting::HostMain(argc, argv); |
1197 } | 1232 } |
1198 #endif // !defined(OS_WIN) | 1233 #endif // !defined(OS_WIN) |
OLD | NEW |