| Index: remoting/host/daemon_process_win.cc
|
| diff --git a/remoting/host/daemon_process_win.cc b/remoting/host/daemon_process_win.cc
|
| index 5603c9a7ec75f857ee4bdf615f38875b6140cda0..6bf2e6e5914bd7e2e4b9e3820ace57dc00136853 100644
|
| --- a/remoting/host/daemon_process_win.cc
|
| +++ b/remoting/host/daemon_process_win.cc
|
| @@ -20,6 +20,8 @@
|
| #include "ipc/ipc_message.h"
|
| #include "ipc/ipc_message_macros.h"
|
| #include "remoting/base/auto_thread_task_runner.h"
|
| +#include "remoting/base/scoped_sc_handle_win.h"
|
| +#include "remoting/host/branding.h"
|
| #include "remoting/host/chromoting_messages.h"
|
| #include "remoting/host/desktop_session_win.h"
|
| #include "remoting/host/host_exit_codes.h"
|
| @@ -51,6 +53,7 @@ class DaemonProcessWin : public DaemonProcess {
|
|
|
| // WorkerProcessIpcDelegate implementation.
|
| virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
|
| + virtual void OnPermanentError(int exit_code) OVERRIDE;
|
|
|
| // DaemonProcess overrides.
|
| virtual void SendToNetwork(IPC::Message* message) OVERRIDE;
|
| @@ -69,6 +72,9 @@ class DaemonProcessWin : public DaemonProcess {
|
| const tracked_objects::Location& location) OVERRIDE;
|
| virtual void LaunchNetworkProcess() OVERRIDE;
|
|
|
| + // Changes the service start type to 'manual'.
|
| + void DisableAutoStart();
|
| +
|
| private:
|
| scoped_ptr<WorkerProcessLauncher> network_launcher_;
|
|
|
| @@ -99,6 +105,16 @@ void DaemonProcessWin::OnChannelConnected(int32 peer_pid) {
|
| DaemonProcess::OnChannelConnected(peer_pid);
|
| }
|
|
|
| +void DaemonProcessWin::OnPermanentError(int exit_code) {
|
| + // Change the service start type to 'manual' if the host has been deleted
|
| + // remotely. This way the host will not be started every time the machine
|
| + // boots until the user re-enable it again.
|
| + if (exit_code == kInvalidHostIdExitCode)
|
| + DisableAutoStart();
|
| +
|
| + DaemonProcess::OnPermanentError(exit_code);
|
| +}
|
| +
|
| void DaemonProcessWin::SendToNetwork(IPC::Message* message) {
|
| if (network_launcher_) {
|
| network_launcher_->Send(message);
|
| @@ -186,4 +202,42 @@ scoped_ptr<DaemonProcess> DaemonProcess::Create(
|
| return daemon_process.PassAs<DaemonProcess>();
|
| }
|
|
|
| +void DaemonProcessWin::DisableAutoStart() {
|
| + ScopedScHandle scmanager(
|
| + OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE,
|
| + SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE));
|
| + if (!scmanager.IsValid()) {
|
| + LOG_GETLASTERROR(INFO)
|
| + << "Failed to connect to the service control manager";
|
| + return;
|
| + }
|
| +
|
| + DWORD desired_access = SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS;
|
| + ScopedScHandle service(
|
| + OpenService(scmanager, kWindowsServiceName, desired_access));
|
| + if (!service.IsValid()) {
|
| + LOG_GETLASTERROR(INFO)
|
| + << "Failed to open to the '" << kWindowsServiceName << "' service";
|
| + return;
|
| + }
|
| +
|
| + // Change the service start type to 'manual'. All |NULL| parameters below mean
|
| + // that there is no change to the corresponding service parameter.
|
| + if (!ChangeServiceConfig(service,
|
| + SERVICE_NO_CHANGE,
|
| + SERVICE_DEMAND_START,
|
| + SERVICE_NO_CHANGE,
|
| + NULL,
|
| + NULL,
|
| + NULL,
|
| + NULL,
|
| + NULL,
|
| + NULL,
|
| + NULL)) {
|
| + LOG_GETLASTERROR(INFO)
|
| + << "Failed to change the '" << kWindowsServiceName
|
| + << "'service start type to 'manual'";
|
| + }
|
| +}
|
| +
|
| } // namespace remoting
|
|
|