Index: remoting/host/elevated_controller_win.cc |
diff --git a/remoting/host/elevated_controller_win.cc b/remoting/host/elevated_controller_win.cc |
index e5b655e6439a262484ce1fee3f2527a01293b040..e23660ca9a4b667d05f3f45ac53847bc3f56858e 100644 |
--- a/remoting/host/elevated_controller_win.cc |
+++ b/remoting/host/elevated_controller_win.cc |
@@ -327,7 +327,39 @@ STDMETHODIMP ElevatedControllerWin::StopDaemon() { |
} |
STDMETHODIMP ElevatedControllerWin::UpdateConfig(BSTR config) { |
- return E_NOTIMPL; |
+ // Parse the config. |
+ std::string config_str = UTF16ToUTF8( |
+ string16(static_cast<char16*>(config), ::SysStringLen(config))); |
+ scoped_ptr<base::Value> config_value(base::JSONReader::Read(config_str)); |
+ if (!config_value.get()) { |
+ return E_FAIL; |
+ } |
+ base::DictionaryValue* config_dict = NULL; |
+ if (!config_value->GetAsDictionary(&config_dict)) { |
+ return E_FAIL; |
+ } |
+ // 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.
|
+ 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
|
+ return E_FAIL; |
+ } |
+ // Get the old config. |
+ FilePath config_dir = remoting::GetConfigDir(); |
+ scoped_ptr<base::DictionaryValue> config_old; |
+ HRESULT hr = ReadConfig(config_dir.Append(kConfigFileName), &config_old); |
+ if (FAILED(hr)) { |
+ 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.
|
+ } |
+ // Merge items from the given config into the old config. |
+ config_old->MergeDictionary(config_dict); |
+ // Write the updated config. |
+ if (!file_util::CreateDirectory(config_dir)) { |
+ return HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED); |
+ } |
+ std::string config_updated_str; |
+ base::JSONWriter::Write(config_old.get(), &config_updated_str); |
+ return WriteConfig(config_dir.Append(kConfigFileName), |
+ config_updated_str.c_str(), |
+ config_updated_str.size()); |
} |
HRESULT ElevatedControllerWin::OpenService(ScopedScHandle* service_out) { |