From ab0b56aef33f04f4d7a352d5790b2d9cd9e7d6d3 Mon Sep 17 00:00:00 2001 From: Paul Crowley Date: Tue, 19 Jul 2016 15:29:53 -0700 Subject: [PATCH] Don't fail if a key we want to delete is already deleted This can happen when cleaning up stale users at boot time. Bug: 30158800 Change-Id: I2733d8d525fc79b7f05eb2225b7e6e14c4da277f --- Ext4Crypt.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Ext4Crypt.cpp b/Ext4Crypt.cpp index 09c33a0..7d65364 100644 --- a/Ext4Crypt.cpp +++ b/Ext4Crypt.cpp @@ -534,7 +534,12 @@ bool e4crypt_destroy_user_key(userid_t user_id) { for (auto const path: get_ce_key_paths(get_ce_key_directory_path(user_id))) { success &= android::vold::destroyKey(path); } - success &= android::vold::destroyKey(get_de_key_path(user_id)); + auto de_key_path = get_de_key_path(user_id); + if (path_exists(de_key_path)) { + success &= android::vold::destroyKey(de_key_path); + } else { + LOG(INFO) << "Not present so not erasing: " << de_key_path; + } } return success; }