| 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/file_version_info.h" | 10 #include "base/file_version_info.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/process_util.h" | 16 #include "base/process_util.h" |
| 17 #include "base/stringize_macros.h" | |
| 18 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 19 #include "base/values.h" | 18 #include "base/values.h" |
| 20 #include "base/win/scoped_handle.h" | 19 #include "base/win/scoped_handle.h" |
| 21 #include "remoting/host/branding.h" | 20 #include "remoting/host/branding.h" |
| 22 #include "remoting/host/elevated_controller_resource.h" | 21 #include "remoting/host/elevated_controller_resource.h" |
| 23 #include "remoting/host/verify_config_window_win.h" | 22 #include "remoting/host/verify_config_window_win.h" |
| 24 | 23 |
| 25 namespace { | 24 namespace { |
| 26 | 25 |
| 27 // The maximum size of the configuration file. "1MB ought to be enough" for any | 26 // The maximum size of the configuration file. "1MB ought to be enough" for any |
| 28 // reasonable configuration we will ever need. 1MB is low enough to make | 27 // reasonable configuration we will ever need. 1MB is low enough to make |
| 29 // the probability of out of memory situation fairly low. OOM is still possible | 28 // the probability of out of memory situation fairly low. OOM is still possible |
| 30 // and we will crash if it occurs. | 29 // and we will crash if it occurs. |
| 31 const size_t kMaxConfigFileSize = 1024 * 1024; | 30 const size_t kMaxConfigFileSize = 1024 * 1024; |
| 32 | 31 |
| 33 // The host configuration file name. | 32 // The host configuration file name. |
| 34 const FilePath::CharType kConfigFileName[] = FILE_PATH_LITERAL("host.json"); | 33 const FilePath::CharType kConfigFileName[] = FILE_PATH_LITERAL("host.json"); |
| 35 | 34 |
| 36 // The unprivileged configuration file name. | 35 // The unprivileged configuration file name. |
| 37 const FilePath::CharType kUnprivilegedConfigFileName[] = | 36 const FilePath::CharType kUnprivilegedConfigFileName[] = |
| 38 FILE_PATH_LITERAL("host_unprivileged.json"); | 37 FILE_PATH_LITERAL("host_unprivileged.json"); |
| 39 | 38 |
| 40 // The extension for the temporary file. | 39 // The extension for the temporary file. |
| 41 const FilePath::CharType kTempFileExtension[] = FILE_PATH_LITERAL("json~"); | 40 const FilePath::CharType kTempFileExtension[] = FILE_PATH_LITERAL("json~"); |
| 42 | 41 |
| 43 // The host configuration file security descriptor that enables full access to | 42 // The host configuration file security descriptor that enables full access to |
| 44 // Local System and built-in administrators only. | 43 // Local System and built-in administrators only. |
| 45 const char16 kConfigFileSecurityDescriptor[] = | 44 const wchar_t kConfigFileSecurityDescriptor[] = |
| 46 TO_L_STRING("O:BAG:BAD:(A;;GA;;;SY)(A;;GA;;;BA)"); | 45 L"O:BAG:BAD:(A;;GA;;;SY)(A;;GA;;;BA)"; |
| 47 | 46 |
| 48 const char16 kUnprivilegedConfigFileSecurityDescriptor[] = | 47 const wchar_t kUnprivilegedConfigFileSecurityDescriptor[] = |
| 49 TO_L_STRING("O:BAG:BAD:(A;;GA;;;SY)(A;;GA;;;BA)(A;;GR;;;AU)"); | 48 L"O:BAG:BAD:(A;;GA;;;SY)(A;;GA;;;BA)(A;;GR;;;AU)"; |
| 50 | 49 |
| 51 // Configuration keys. | 50 // Configuration keys. |
| 52 const char kHostId[] = "host_id"; | 51 const char kHostId[] = "host_id"; |
| 53 const char kXmppLogin[] = "xmpp_login"; | 52 const char kXmppLogin[] = "xmpp_login"; |
| 54 const char kHostSecretHash[] = "host_secret_hash"; | 53 const char kHostSecretHash[] = "host_secret_hash"; |
| 55 | 54 |
| 56 // The configuration keys that cannot be specified in UpdateConfig(). | 55 // The configuration keys that cannot be specified in UpdateConfig(). |
| 57 const char* const kReadonlyKeys[] = { kHostId, kXmppLogin }; | 56 const char* const kReadonlyKeys[] = { kHostId, kXmppLogin }; |
| 58 | 57 |
| 59 // The configuration keys whose values may be read by GetConfig(). | 58 // The configuration keys whose values may be read by GetConfig(). |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 config_out->reset(dictionary); | 134 config_out->reset(dictionary); |
| 136 return S_OK; | 135 return S_OK; |
| 137 } | 136 } |
| 138 | 137 |
| 139 FilePath GetTempLocationFor(const FilePath& filename) { | 138 FilePath GetTempLocationFor(const FilePath& filename) { |
| 140 return filename.ReplaceExtension(kTempFileExtension); | 139 return filename.ReplaceExtension(kTempFileExtension); |
| 141 } | 140 } |
| 142 | 141 |
| 143 // Writes a config file to a temporary location. | 142 // Writes a config file to a temporary location. |
| 144 HRESULT WriteConfigFileToTemp(const FilePath& filename, | 143 HRESULT WriteConfigFileToTemp(const FilePath& filename, |
| 145 const char16* security_descriptor, | 144 const wchar_t* security_descriptor, |
| 146 const char* content, | 145 const char* content, |
| 147 size_t length) { | 146 size_t length) { |
| 148 // Create a security descriptor for the configuration file. | 147 // Create a security descriptor for the configuration file. |
| 149 SECURITY_ATTRIBUTES security_attributes; | 148 SECURITY_ATTRIBUTES security_attributes; |
| 150 security_attributes.nLength = sizeof(security_attributes); | 149 security_attributes.nLength = sizeof(security_attributes); |
| 151 security_attributes.bInheritHandle = FALSE; | 150 security_attributes.bInheritHandle = FALSE; |
| 152 | 151 |
| 153 ULONG security_descriptor_length = 0; | 152 ULONG security_descriptor_length = 0; |
| 154 if (!ConvertStringSecurityDescriptorToSecurityDescriptorW( | 153 if (!ConvertStringSecurityDescriptorToSecurityDescriptorW( |
| 155 security_descriptor, | 154 security_descriptor, |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 << "Failed to open to the '" << kWindowsServiceName << "' service"; | 504 << "Failed to open to the '" << kWindowsServiceName << "' service"; |
| 506 | 505 |
| 507 return HRESULT_FROM_WIN32(error); | 506 return HRESULT_FROM_WIN32(error); |
| 508 } | 507 } |
| 509 | 508 |
| 510 service_out->Set(service.Take()); | 509 service_out->Set(service.Take()); |
| 511 return S_OK; | 510 return S_OK; |
| 512 } | 511 } |
| 513 | 512 |
| 514 } // namespace remoting | 513 } // namespace remoting |
| OLD | NEW |