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

Side by Side Diff: remoting/host/elevated_controller_win.cc

Issue 10103010: [Chromoting] Implement UpdateConfig() for the Windows host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "remoting/host/elevated_controller_win.h" 5 #include "remoting/host/elevated_controller_win.h"
6 6
7 #include <sddl.h> 7 #include <sddl.h>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 LOG_GETLASTERROR(ERROR) 320 LOG_GETLASTERROR(ERROR)
321 << "Failed to stop the '" << kWindowsServiceName << "'service"; 321 << "Failed to stop the '" << kWindowsServiceName << "'service";
322 return HRESULT_FROM_WIN32(error); 322 return HRESULT_FROM_WIN32(error);
323 } 323 }
324 } 324 }
325 325
326 return S_OK; 326 return S_OK;
327 } 327 }
328 328
329 STDMETHODIMP ElevatedControllerWin::UpdateConfig(BSTR config) { 329 STDMETHODIMP ElevatedControllerWin::UpdateConfig(BSTR config) {
330 return E_NOTIMPL; 330 // Parse the config.
331 std::string config_str = UTF16ToUTF8(
332 string16(static_cast<char16*>(config), ::SysStringLen(config)));
333 scoped_ptr<base::Value> config_value(base::JSONReader::Read(config_str));
334 if (!config_value.get()) {
335 return E_FAIL;
336 }
337 base::DictionaryValue* config_dict = NULL;
338 if (!config_value->GetAsDictionary(&config_dict)) {
339 return E_FAIL;
340 }
341 // The config must not contain host_id or xmpp_login.
alexeypa (please no reviews) 2012/04/16 22:36:35 It is better to have an explicit list of banned ke
simonmorris 2012/04/16 23:20:23 Done.
342 if (config_dict->HasKey(kHostId) || config_dict->HasKey(kXmppLogin)) {
Jamie 2012/04/16 22:26:48 This is probably not a discussion for this CL (as
alexeypa (please no reviews) 2012/04/16 22:36:35 The last time we discussed this with sergeyu@ the
343 return E_FAIL;
344 }
345 // Get the old config.
346 FilePath config_dir = remoting::GetConfigDir();
347 scoped_ptr<base::DictionaryValue> config_old;
348 HRESULT hr = ReadConfig(config_dir.Append(kConfigFileName), &config_old);
349 if (FAILED(hr)) {
350 config_old.reset(new base::DictionaryValue());
alexeypa (please no reviews) 2012/04/16 22:36:35 I don't think we should allow to update a non-exis
simonmorris 2012/04/16 23:20:23 Done.
351 }
352 // Merge items from the given config into the old config.
353 config_old->MergeDictionary(config_dict);
354 // Write the updated config.
355 if (!file_util::CreateDirectory(config_dir)) {
356 return HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED);
357 }
358 std::string config_updated_str;
359 base::JSONWriter::Write(config_old.get(), &config_updated_str);
360 return WriteConfig(config_dir.Append(kConfigFileName),
361 config_updated_str.c_str(),
362 config_updated_str.size());
331 } 363 }
332 364
333 HRESULT ElevatedControllerWin::OpenService(ScopedScHandle* service_out) { 365 HRESULT ElevatedControllerWin::OpenService(ScopedScHandle* service_out) {
334 DWORD error; 366 DWORD error;
335 367
336 ScopedScHandle scmanager( 368 ScopedScHandle scmanager(
337 ::OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASE, 369 ::OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASE,
338 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE)); 370 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE));
339 if (!scmanager.IsValid()) { 371 if (!scmanager.IsValid()) {
340 error = GetLastError(); 372 error = GetLastError();
(...skipping 13 matching lines...) Expand all
354 << "Failed to open to the '" << kWindowsServiceName << "' service"; 386 << "Failed to open to the '" << kWindowsServiceName << "' service";
355 387
356 return HRESULT_FROM_WIN32(error); 388 return HRESULT_FROM_WIN32(error);
357 } 389 }
358 390
359 service_out->Set(service.Take()); 391 service_out->Set(service.Take());
360 return S_OK; 392 return S_OK;
361 } 393 }
362 394
363 } // namespace remoting 395 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698