| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 return password; | 93 return password; |
| 94 return AddRandomPasswordInLibsecret(); | 94 return AddRandomPasswordInLibsecret(); |
| 95 } | 95 } |
| 96 std::string password( | 96 std::string password( |
| 97 LibsecretLoader::secret_value_get_text(password_libsecret)); | 97 LibsecretLoader::secret_value_get_text(password_libsecret)); |
| 98 LibsecretLoader::secret_value_unref(password_libsecret); | 98 LibsecretLoader::secret_value_unref(password_libsecret); |
| 99 return password; | 99 return password; |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool KeyStorageLibsecret::Init() { | 102 bool KeyStorageLibsecret::Init() { |
| 103 return LibsecretLoader::EnsureLibsecretLoaded(); | 103 bool loaded = LibsecretLoader::EnsureLibsecretLoaded(); |
| 104 if (loaded) |
| 105 LibsecretLoader::EnsureKeyringUnlocked(); |
| 106 return loaded; |
| 104 } | 107 } |
| 105 | 108 |
| 106 std::string KeyStorageLibsecret::Migrate() { | 109 std::string KeyStorageLibsecret::Migrate() { |
| 107 GError* error = nullptr; | 110 GError* error = nullptr; |
| 108 LibsecretAttributesBuilder attrs; | 111 LibsecretAttributesBuilder attrs; |
| 109 | 112 |
| 110 // Detect old entry. | 113 // Detect old entry. |
| 111 GList* search_results = LibsecretLoader::secret_service_search_sync( | 114 GList* search_results = LibsecretLoader::secret_service_search_sync( |
| 112 nullptr /* default secret service */, &kKeystoreSchemaV1, attrs.Get(), | 115 nullptr /* default secret service */, &kKeystoreSchemaV1, attrs.Get(), |
| 113 static_cast<SecretSearchFlags>(SECRET_SEARCH_UNLOCK | | 116 static_cast<SecretSearchFlags>(SECRET_SEARCH_UNLOCK | |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 if (error) { | 151 if (error) { |
| 149 VLOG(1) << "OSCrypt failed to delete deprecated password. " | 152 VLOG(1) << "OSCrypt failed to delete deprecated password. " |
| 150 << error->message; | 153 << error->message; |
| 151 g_error_free(error); | 154 g_error_free(error); |
| 152 } | 155 } |
| 153 | 156 |
| 154 VLOG(1) << "OSCrypt migrated from deprecated password."; | 157 VLOG(1) << "OSCrypt migrated from deprecated password."; |
| 155 | 158 |
| 156 return password; | 159 return password; |
| 157 } | 160 } |
| OLD | NEW |