Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
| 12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "base/win/scoped_handle.h" | 17 #include "base/win/scoped_handle.h" |
| 18 #include "remoting/host/branding.h" | 18 #include "remoting/host/branding.h" |
| 19 #include "remoting/host/elevated_controller_resource.h" | |
| 20 #include "remoting/host/verify_config_window_win.h" | |
| 21 | |
| 22 // HINSTANCE from WinMain. This is needed to find our dialog resource. | |
| 23 // This is defined in elevated_controller_module_win.cc | |
| 24 extern HINSTANCE g_hInstance; | |
| 19 | 25 |
| 20 namespace { | 26 namespace { |
| 21 | 27 |
| 22 // The host configuration file name. | 28 // The host configuration file name. |
| 23 const FilePath::CharType kConfigFileName[] = FILE_PATH_LITERAL("host.json"); | 29 const FilePath::CharType kConfigFileName[] = FILE_PATH_LITERAL("host.json"); |
| 24 | 30 |
| 25 // The extension for the temporary file. | 31 // The extension for the temporary file. |
| 26 const FilePath::CharType kTempFileExtension[] = FILE_PATH_LITERAL("json~"); | 32 const FilePath::CharType kTempFileExtension[] = FILE_PATH_LITERAL("json~"); |
| 27 | 33 |
| 28 // The host configuration file security descriptor that enables full access to | 34 // The host configuration file security descriptor that enables full access to |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 } | 95 } |
| 90 | 96 |
| 91 // Writes the configuration file up to |kMaxConfigFileSize| in size. | 97 // Writes the configuration file up to |kMaxConfigFileSize| in size. |
| 92 HRESULT WriteConfig(const FilePath& filename, | 98 HRESULT WriteConfig(const FilePath& filename, |
| 93 const char* content, | 99 const char* content, |
| 94 size_t length) { | 100 size_t length) { |
| 95 if (length > kMaxConfigFileSize) { | 101 if (length > kMaxConfigFileSize) { |
| 96 return E_FAIL; | 102 return E_FAIL; |
| 97 } | 103 } |
| 98 | 104 |
| 105 // Extract the configuration data that the user will verify. | |
| 106 scoped_ptr<base::Value> configValue(base::JSONReader::Read(content)); | |
|
alexeypa (please no reviews)
2012/04/12 21:20:41
configValue -> config_value
simonmorris
2012/04/12 22:11:44
Done.
| |
| 107 if (!configValue.get()) { | |
| 108 return E_FAIL; | |
| 109 } | |
| 110 base::DictionaryValue* configDict = NULL; | |
|
alexeypa (please no reviews)
2012/04/12 21:20:41
configDict -> config_dict.
simonmorris
2012/04/12 22:11:44
Done.
| |
| 111 if (!configValue->GetAsDictionary(&configDict)) { | |
| 112 return E_FAIL; | |
| 113 } | |
| 114 std::string email, host_id, host_secret_hash; | |
| 115 if (!configDict->GetString("xmpp_login", &email) || | |
| 116 !configDict->GetString("host_id", &host_id) || | |
| 117 !configDict->GetString("host_secret_hash", &host_secret_hash)) { | |
| 118 return E_FAIL; | |
| 119 } | |
| 120 | |
| 121 // Ask the user to verify the configuration. | |
| 122 remoting::VerifyConfigWindowWin verifyWin(email, host_id, host_secret_hash); | |
|
alexeypa (please no reviews)
2012/04/12 21:20:41
verifyWin -> verify_win
simonmorris
2012/04/12 22:11:44
Done.
| |
| 123 if (!verifyWin.Run()) { | |
| 124 return E_FAIL; | |
|
alexeypa (please no reviews)
2012/04/12 21:20:41
HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) _maybe_ a
simonmorris
2012/04/12 22:11:44
This way is consistent with the existing code, whi
| |
| 125 } | |
| 126 | |
| 99 // Create a security descriptor for the configuration file. | 127 // Create a security descriptor for the configuration file. |
| 100 SECURITY_ATTRIBUTES security_attributes; | 128 SECURITY_ATTRIBUTES security_attributes; |
| 101 security_attributes.nLength = sizeof(security_attributes); | 129 security_attributes.nLength = sizeof(security_attributes); |
| 102 security_attributes.bInheritHandle = FALSE; | 130 security_attributes.bInheritHandle = FALSE; |
| 103 | 131 |
| 104 ULONG security_descriptor_length = 0; | 132 ULONG security_descriptor_length = 0; |
| 105 if (!ConvertStringSecurityDescriptorToSecurityDescriptorA( | 133 if (!ConvertStringSecurityDescriptorToSecurityDescriptorA( |
| 106 kConfigFileSecurityDescriptor, | 134 kConfigFileSecurityDescriptor, |
| 107 SDDL_REVISION_1, | 135 SDDL_REVISION_1, |
| 108 reinterpret_cast<PSECURITY_DESCRIPTOR*>( | 136 reinterpret_cast<PSECURITY_DESCRIPTOR*>( |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 << "Failed to open to the '" << kWindowsServiceName << "' service"; | 316 << "Failed to open to the '" << kWindowsServiceName << "' service"; |
| 289 | 317 |
| 290 return HRESULT_FROM_WIN32(error); | 318 return HRESULT_FROM_WIN32(error); |
| 291 } | 319 } |
| 292 | 320 |
| 293 service_out->Set(service.Take()); | 321 service_out->Set(service.Take()); |
| 294 return S_OK; | 322 return S_OK; |
| 295 } | 323 } |
| 296 | 324 |
| 297 } // namespace remoting | 325 } // namespace remoting |
| OLD | NEW |