| 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" |
| 19 | 21 |
| 20 namespace { | 22 namespace { |
| 21 | 23 |
| 22 // The host configuration file name. | 24 // The host configuration file name. |
| 23 const FilePath::CharType kConfigFileName[] = FILE_PATH_LITERAL("host.json"); | 25 const FilePath::CharType kConfigFileName[] = FILE_PATH_LITERAL("host.json"); |
| 24 | 26 |
| 25 // The extension for the temporary file. | 27 // The extension for the temporary file. |
| 26 const FilePath::CharType kTempFileExtension[] = FILE_PATH_LITERAL("json~"); | 28 const FilePath::CharType kTempFileExtension[] = FILE_PATH_LITERAL("json~"); |
| 27 | 29 |
| 28 // The host configuration file security descriptor that enables full access to | 30 // 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 } | 91 } |
| 90 | 92 |
| 91 // Writes the configuration file up to |kMaxConfigFileSize| in size. | 93 // Writes the configuration file up to |kMaxConfigFileSize| in size. |
| 92 HRESULT WriteConfig(const FilePath& filename, | 94 HRESULT WriteConfig(const FilePath& filename, |
| 93 const char* content, | 95 const char* content, |
| 94 size_t length) { | 96 size_t length) { |
| 95 if (length > kMaxConfigFileSize) { | 97 if (length > kMaxConfigFileSize) { |
| 96 return E_FAIL; | 98 return E_FAIL; |
| 97 } | 99 } |
| 98 | 100 |
| 101 // Extract the configuration data that the user will verify. |
| 102 scoped_ptr<base::Value> config_value(base::JSONReader::Read(content)); |
| 103 if (!config_value.get()) { |
| 104 return E_FAIL; |
| 105 } |
| 106 base::DictionaryValue* config_dict = NULL; |
| 107 if (!config_value->GetAsDictionary(&config_dict)) { |
| 108 return E_FAIL; |
| 109 } |
| 110 std::string email, host_id, host_secret_hash; |
| 111 if (!config_dict->GetString("xmpp_login", &email) || |
| 112 !config_dict->GetString("host_id", &host_id) || |
| 113 !config_dict->GetString("host_secret_hash", &host_secret_hash)) { |
| 114 return E_FAIL; |
| 115 } |
| 116 |
| 117 // Ask the user to verify the configuration. |
| 118 remoting::VerifyConfigWindowWin verify_win(email, host_id, host_secret_hash); |
| 119 if (!verify_win.Run()) { |
| 120 return E_FAIL; |
| 121 } |
| 122 |
| 99 // Create a security descriptor for the configuration file. | 123 // Create a security descriptor for the configuration file. |
| 100 SECURITY_ATTRIBUTES security_attributes; | 124 SECURITY_ATTRIBUTES security_attributes; |
| 101 security_attributes.nLength = sizeof(security_attributes); | 125 security_attributes.nLength = sizeof(security_attributes); |
| 102 security_attributes.bInheritHandle = FALSE; | 126 security_attributes.bInheritHandle = FALSE; |
| 103 | 127 |
| 104 ULONG security_descriptor_length = 0; | 128 ULONG security_descriptor_length = 0; |
| 105 if (!ConvertStringSecurityDescriptorToSecurityDescriptorA( | 129 if (!ConvertStringSecurityDescriptorToSecurityDescriptorA( |
| 106 kConfigFileSecurityDescriptor, | 130 kConfigFileSecurityDescriptor, |
| 107 SDDL_REVISION_1, | 131 SDDL_REVISION_1, |
| 108 reinterpret_cast<PSECURITY_DESCRIPTOR*>( | 132 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"; | 312 << "Failed to open to the '" << kWindowsServiceName << "' service"; |
| 289 | 313 |
| 290 return HRESULT_FROM_WIN32(error); | 314 return HRESULT_FROM_WIN32(error); |
| 291 } | 315 } |
| 292 | 316 |
| 293 service_out->Set(service.Take()); | 317 service_out->Set(service.Take()); |
| 294 return S_OK; | 318 return S_OK; |
| 295 } | 319 } |
| 296 | 320 |
| 297 } // namespace remoting | 321 } // namespace remoting |
| OLD | NEW |