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

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: rebased. 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') | no next file with comments »
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 1a8bec6145d4310ee041f44e2224913fd2d3071a..86c0aa4d310072628583e3493a83ac9327078269 100644
--- a/remoting/host/elevated_controller_win.cc
+++ b/remoting/host/elevated_controller_win.cc
@@ -228,6 +228,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) {
@@ -248,6 +268,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();
@@ -279,9 +319,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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698