Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc

Issue 2818393002: cros: Mount the existing eCryptfs vault to start migration. (Closed)
Patch Set: FakeCryptohomeClient::MountEx should succeed when |to_migrate_from_ecryptfs| is true. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_han dler.h" 5 #include "chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_han dler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/system/devicetype_utils.h" 10 #include "ash/system/devicetype_utils.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 247 }
248 UpdateUIState(UIState::READY); 248 UpdateUIState(UIState::READY);
249 249
250 should_migrate_on_enough_battery_ = true; 250 should_migrate_on_enough_battery_ = true;
251 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate(); 251 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate();
252 } 252 }
253 253
254 void EncryptionMigrationScreenHandler::StartMigration() { 254 void EncryptionMigrationScreenHandler::StartMigration() {
255 UpdateUIState(UIState::MIGRATING); 255 UpdateUIState(UIState::MIGRATING);
256 256
257 // Mount the existing eCryptfs vault to a temporary location for migration.
258 cryptohome::MountParameters mount(false);
259 mount.to_migrate_from_ecryptfs = true;
260 cryptohome::HomedirMethods::GetInstance()->MountEx(
261 cryptohome::Identification(user_context_.GetAccountId()),
262 cryptohome::Authorization(GetAuthKey()), mount,
263 base::Bind(&EncryptionMigrationScreenHandler::OnMountExistingVault,
264 weak_ptr_factory_.GetWeakPtr()));
265 }
266
267 void EncryptionMigrationScreenHandler::OnMountExistingVault(
268 bool success,
269 cryptohome::MountError return_code,
270 const std::string& mount_hash) {
271 if (!success || return_code != cryptohome::MOUNT_ERROR_NONE) {
272 UpdateUIState(UIState::MIGRATION_FAILED);
273 return;
274 }
275
257 DBusThreadManager::Get() 276 DBusThreadManager::Get()
258 ->GetCryptohomeClient() 277 ->GetCryptohomeClient()
259 ->SetDircryptoMigrationProgressHandler( 278 ->SetDircryptoMigrationProgressHandler(
260 base::Bind(&EncryptionMigrationScreenHandler::OnMigrationProgress, 279 base::Bind(&EncryptionMigrationScreenHandler::OnMigrationProgress,
261 weak_ptr_factory_.GetWeakPtr())); 280 weak_ptr_factory_.GetWeakPtr()));
281 cryptohome::HomedirMethods::GetInstance()->MigrateToDircrypto(
282 cryptohome::Identification(user_context_.GetAccountId()),
283 cryptohome::Authorization(GetAuthKey()),
hashimoto 2017/04/17 06:30:12 Authorization argument was removed from MigrateToD
fukino 2017/04/17 06:56:59 Done.
284 base::Bind(&EncryptionMigrationScreenHandler::OnMigrationRequested,
285 weak_ptr_factory_.GetWeakPtr()));
286 }
262 287
288 cryptohome::KeyDefinition EncryptionMigrationScreenHandler::GetAuthKey() {
263 // |auth_key| is created in the same manner as CryptohomeAuthenticator. 289 // |auth_key| is created in the same manner as CryptohomeAuthenticator.
264 const Key* key = user_context_.GetKey(); 290 const Key* key = user_context_.GetKey();
265 // If the |key| is a plain text password, crash rather than attempting to 291 // If the |key| is a plain text password, crash rather than attempting to
266 // mount the cryptohome with a plain text password. 292 // mount the cryptohome with a plain text password.
267 CHECK_NE(Key::KEY_TYPE_PASSWORD_PLAIN, key->GetKeyType()); 293 CHECK_NE(Key::KEY_TYPE_PASSWORD_PLAIN, key->GetKeyType());
268 // Set the authentication's key label to an empty string, which is a wildcard 294 // Set the authentication's key label to an empty string, which is a wildcard
269 // allowing any key to match. This is necessary because cryptohomes created by 295 // allowing any key to match. This is necessary because cryptohomes created by
270 // Chrome OS M38 and older will have a legacy key with no label while those 296 // Chrome OS M38 and older will have a legacy key with no label while those
271 // created by Chrome OS M39 and newer will have a key with the label 297 // created by Chrome OS M39 and newer will have a key with the label
272 // kCryptohomeGAIAKeyLabel. 298 // kCryptohomeGAIAKeyLabel.
273 const cryptohome::KeyDefinition auth_key(key->GetSecret(), std::string(), 299 return cryptohome::KeyDefinition(key->GetSecret(), std::string(),
274 cryptohome::PRIV_DEFAULT); 300 cryptohome::PRIV_DEFAULT);
275 cryptohome::HomedirMethods::GetInstance()->MigrateToDircrypto(
276 cryptohome::Identification(user_context_.GetAccountId()),
277 cryptohome::Authorization(auth_key),
278 base::Bind(&EncryptionMigrationScreenHandler::OnMigrationRequested,
279 weak_ptr_factory_.GetWeakPtr()));
280 } 301 }
281 302
282 void EncryptionMigrationScreenHandler::OnMigrationProgress( 303 void EncryptionMigrationScreenHandler::OnMigrationProgress(
283 cryptohome::DircryptoMigrationStatus status, 304 cryptohome::DircryptoMigrationStatus status,
284 uint64_t current, 305 uint64_t current,
285 uint64_t total) { 306 uint64_t total) {
286 switch (status) { 307 switch (status) {
287 case cryptohome::DIRCRYPTO_MIGRATION_INITIALIZING: 308 case cryptohome::DIRCRYPTO_MIGRATION_INITIALIZING:
288 UpdateUIState(UIState::MIGRATING); 309 UpdateUIState(UIState::MIGRATING);
289 break; 310 break;
(...skipping 21 matching lines...) Expand all
311 void EncryptionMigrationScreenHandler::OnMigrationRequested(bool success) { 332 void EncryptionMigrationScreenHandler::OnMigrationRequested(bool success) {
312 // This function is called when MigrateToDircrypto is correctly requested. 333 // This function is called when MigrateToDircrypto is correctly requested.
313 // It does not mean that the migration is completed. We should know the 334 // It does not mean that the migration is completed. We should know the
314 // completion by DircryptoMigrationProgressHandler. success == false means a 335 // completion by DircryptoMigrationProgressHandler. success == false means a
315 // failure in DBus communication. 336 // failure in DBus communication.
316 // TODO(fukino): Handle this case. Should we retry or restart? 337 // TODO(fukino): Handle this case. Should we retry or restart?
317 DCHECK(success); 338 DCHECK(success);
318 } 339 }
319 340
320 } // namespace chromeos 341 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698