Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/os_crypt/key_storage_libsecret.h" | 5 #include "components/os_crypt/key_storage_libsecret.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "components/os_crypt/libsecret_util_linux.h" | 10 #include "components/os_crypt/libsecret_util_linux.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 if (!success) { | 66 if (!success) { |
| 67 VLOG(1) << "Libsecret lookup failed."; | 67 VLOG(1) << "Libsecret lookup failed."; |
| 68 return std::string(); | 68 return std::string(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 VLOG(1) << "OSCrypt generated a new password."; | 71 VLOG(1) << "OSCrypt generated a new password."; |
| 72 return password; | 72 return password; |
| 73 } | 73 } |
| 74 | 74 |
| 75 std::string KeyStorageLibsecret::GetKey() { | 75 std::string KeyStorageLibsecret::GetKey() { |
| 76 LibsecretLoader::EnsureKeyringUnlocked(); | |
|
vasilii
2016/10/28 09:36:24
How often is this method called? Is it enough to u
cfroussios
2016/10/28 11:21:22
GetKey() is called once and its result will be cac
| |
| 77 | |
| 76 GError* error = nullptr; | 78 GError* error = nullptr; |
| 77 LibsecretAttributesBuilder attrs; | 79 LibsecretAttributesBuilder attrs; |
| 78 attrs.Append("application", kApplicationName); | 80 attrs.Append("application", kApplicationName); |
| 79 GList* search_results = LibsecretLoader::secret_service_search_sync( | 81 GList* search_results = LibsecretLoader::secret_service_search_sync( |
| 80 nullptr /* default secret service */, &kKeystoreSchemaV2, attrs.Get(), | 82 nullptr /* default secret service */, &kKeystoreSchemaV2, attrs.Get(), |
| 81 static_cast<SecretSearchFlags>(SECRET_SEARCH_UNLOCK | | 83 static_cast<SecretSearchFlags>(SECRET_SEARCH_UNLOCK | |
| 82 SECRET_SEARCH_LOAD_SECRETS), | 84 SECRET_SEARCH_LOAD_SECRETS), |
| 83 nullptr, &error); | 85 nullptr, &error); |
| 84 if (error) { | 86 if (error) { |
| 85 VLOG(1) << "Libsecret lookup failed: " << error->message; | 87 VLOG(1) << "Libsecret lookup failed: " << error->message; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 if (error) { | 150 if (error) { |
| 149 VLOG(1) << "OSCrypt failed to delete deprecated password. " | 151 VLOG(1) << "OSCrypt failed to delete deprecated password. " |
| 150 << error->message; | 152 << error->message; |
| 151 g_error_free(error); | 153 g_error_free(error); |
| 152 } | 154 } |
| 153 | 155 |
| 154 VLOG(1) << "OSCrypt migrated from deprecated password."; | 156 VLOG(1) << "OSCrypt migrated from deprecated password."; |
| 155 | 157 |
| 156 return password; | 158 return password; |
| 157 } | 159 } |
| OLD | NEW |