Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Unified Diff: remoting/host/elevated_controller_win.cc

Issue 10048003: The Chromoting service should not start automatically unless it was configured from the webapp to d… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/host/host_service_win.h » ('j') | remoting/host/wts_console_monitor_win.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/elevated_controller_win.cc
diff --git a/remoting/host/elevated_controller_win.cc b/remoting/host/elevated_controller_win.cc
index 1c13ffab4c56329b7fa320a313fd7a9762b2ee2b..cb026e5c5e3cb3732496366d9a6187f6c398256f 100644
--- a/remoting/host/elevated_controller_win.cc
+++ b/remoting/host/elevated_controller_win.cc
@@ -227,6 +227,26 @@ STDMETHODIMP ElevatedControllerWin::StartDaemon() {
return hr;
}
+ // Change the service start type to 'auto'.
+ if (!::ChangeServiceConfigW(service,
+ SERVICE_NO_CHANGE,
+ SERVICE_AUTO_START,
+ SERVICE_NO_CHANGE,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL)) {
+ DWORD error = GetLastError();
+ LOG_GETLASTERROR(ERROR)
+ << "Failed to change the '" << kWindowsServiceName
+ << "'service start type to 'auto'";
+ return HRESULT_FROM_WIN32(error);
+ }
+
+ // Start the service.
if (!StartService(service, 0, NULL)) {
DWORD error = GetLastError();
if (error != ERROR_SERVICE_ALREADY_RUNNING) {
@@ -247,6 +267,26 @@ STDMETHODIMP ElevatedControllerWin::StopDaemon() {
return hr;
}
+ // Change the service start type to 'manual'.
+ if (!::ChangeServiceConfigW(service,
+ SERVICE_NO_CHANGE,
+ SERVICE_DEMAND_START,
+ SERVICE_NO_CHANGE,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL)) {
+ DWORD error = GetLastError();
+ LOG_GETLASTERROR(ERROR)
+ << "Failed to change the '" << kWindowsServiceName
+ << "'service start type to 'manual'";
+ return HRESULT_FROM_WIN32(error);
+ }
+
+ // Stop the service.
SERVICE_STATUS status;
if (!ControlService(service, SERVICE_CONTROL_STOP, &status)) {
DWORD error = GetLastError();
@@ -278,9 +318,11 @@ HRESULT ElevatedControllerWin::OpenService(ScopedScHandle* service_out) {
return HRESULT_FROM_WIN32(error);
}
+ DWORD desired_access = SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS |
+ SERVICE_START | SERVICE_STOP;
ScopedScHandle service(
::OpenServiceW(scmanager, UTF8ToUTF16(kWindowsServiceName).c_str(),
- SERVICE_QUERY_STATUS | SERVICE_START | SERVICE_STOP));
+ desired_access));
if (!service.IsValid()) {
error = GetLastError();
LOG_GETLASTERROR(ERROR)
« no previous file with comments | « no previous file | remoting/host/host_service_win.h » ('j') | remoting/host/wts_console_monitor_win.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698