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/win/elevated_controller.h" | 5 #include "remoting/host/win/elevated_controller.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 // Local System and built-in administrators only. | 45 // Local System and built-in administrators only. |
46 const char kConfigFileSecurityDescriptor[] = | 46 const char kConfigFileSecurityDescriptor[] = |
47 "O:BAG:BAD:(A;;GA;;;SY)(A;;GA;;;BA)"; | 47 "O:BAG:BAD:(A;;GA;;;SY)(A;;GA;;;BA)"; |
48 | 48 |
49 const char kUnprivilegedConfigFileSecurityDescriptor[] = | 49 const char kUnprivilegedConfigFileSecurityDescriptor[] = |
50 "O:BAG:BAD:(A;;GA;;;SY)(A;;GA;;;BA)(A;;GR;;;AU)"; | 50 "O:BAG:BAD:(A;;GA;;;SY)(A;;GA;;;BA)(A;;GR;;;AU)"; |
51 | 51 |
52 // Configuration keys. | 52 // Configuration keys. |
53 const char kHostId[] = "host_id"; | 53 const char kHostId[] = "host_id"; |
54 const char kXmppLogin[] = "xmpp_login"; | 54 const char kXmppLogin[] = "xmpp_login"; |
55 const char kHostOwner[] = "host_owner"; | |
55 const char kHostSecretHash[] = "host_secret_hash"; | 56 const char kHostSecretHash[] = "host_secret_hash"; |
56 | 57 |
57 // The configuration keys that cannot be specified in UpdateConfig(). | 58 // The configuration keys that cannot be specified in UpdateConfig(). |
58 const char* const kReadonlyKeys[] = { kHostId, kXmppLogin }; | 59 const char* const kReadonlyKeys[] = { kHostId, kHostOwner, kXmppLogin }; |
59 | 60 |
60 // The configuration keys whose values may be read by GetConfig(). | 61 // The configuration keys whose values may be read by GetConfig(). |
61 const char* const kUnprivilegedConfigKeys[] = { kHostId, kXmppLogin }; | 62 const char* const kUnprivilegedConfigKeys[] = { kHostId, kXmppLogin }; |
62 | 63 |
63 // Determines if the client runs in the security context that allows performing | 64 // Determines if the client runs in the security context that allows performing |
64 // administrative tasks (i.e. the user belongs to the adminstrators group and | 65 // administrative tasks (i.e. the user belongs to the adminstrators group and |
65 // the client runs elevated). | 66 // the client runs elevated). |
66 bool IsClientAdmin() { | 67 bool IsClientAdmin() { |
67 HRESULT hr = CoImpersonateClient(); | 68 HRESULT hr = CoImpersonateClient(); |
68 if (FAILED(hr)) { | 69 if (FAILED(hr)) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 | 216 |
216 // Extract the configuration data that the user will verify. | 217 // Extract the configuration data that the user will verify. |
217 scoped_ptr<base::Value> config_value(base::JSONReader::Read(content)); | 218 scoped_ptr<base::Value> config_value(base::JSONReader::Read(content)); |
218 if (!config_value.get()) { | 219 if (!config_value.get()) { |
219 return E_FAIL; | 220 return E_FAIL; |
220 } | 221 } |
221 base::DictionaryValue* config_dict = NULL; | 222 base::DictionaryValue* config_dict = NULL; |
222 if (!config_value->GetAsDictionary(&config_dict)) { | 223 if (!config_value->GetAsDictionary(&config_dict)) { |
223 return E_FAIL; | 224 return E_FAIL; |
224 } | 225 } |
225 std::string email, host_id, host_secret_hash; | 226 std::string email; |
226 if (!config_dict->GetString(kXmppLogin, &email) || | 227 if (!config_dict->GetString(kHostOwner, &email)) { |
227 !config_dict->GetString(kHostId, &host_id) || | 228 if (!config_dict->GetString(kXmppLogin, &email)) { |
alexeypa (please no reviews)
2013/09/23 22:37:02
nit: no need for this pair of brackets.
| |
229 return E_FAIL; | |
230 } | |
231 } | |
232 std::string host_id, host_secret_hash; | |
233 if (!config_dict->GetString(kHostId, &host_id) || | |
228 !config_dict->GetString(kHostSecretHash, &host_secret_hash)) { | 234 !config_dict->GetString(kHostSecretHash, &host_secret_hash)) { |
229 return E_FAIL; | 235 return E_FAIL; |
230 } | 236 } |
231 | 237 |
232 // Ask the user to verify the configuration (unless the client is admin | 238 // Ask the user to verify the configuration (unless the client is admin |
233 // already). | 239 // already). |
234 if (!IsClientAdmin()) { | 240 if (!IsClientAdmin()) { |
235 remoting::VerifyConfigWindowWin verify_win(email, host_id, | 241 remoting::VerifyConfigWindowWin verify_win(email, host_id, |
236 host_secret_hash); | 242 host_secret_hash); |
237 DWORD error = verify_win.DoModal(owner_window); | 243 DWORD error = verify_win.DoModal(owner_window); |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
522 << "Failed to open to the '" << kWindowsServiceName << "' service"; | 528 << "Failed to open to the '" << kWindowsServiceName << "' service"; |
523 | 529 |
524 return HRESULT_FROM_WIN32(error); | 530 return HRESULT_FROM_WIN32(error); |
525 } | 531 } |
526 | 532 |
527 service_out->Set(service.Take()); | 533 service_out->Set(service.Take()); |
528 return S_OK; | 534 return S_OK; |
529 } | 535 } |
530 | 536 |
531 } // namespace remoting | 537 } // namespace remoting |
OLD | NEW |