From d863b2cd4a0c628d5db7c200f2ee7ec6e734fecf Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 27 May 2021 17:29:10 -0700 Subject: [PATCH] Remove /data/misc/vold/user_keys/ce/${user_id} when no longer needed When a user is removed, vold is deleting the subdirectories of /data/misc/vold/user_keys/ce/${user_id} but not that directory itself. This is unexpected, as none of the user's directories should be left around. Delete it too. Bug: 188702840 Test: pm create-user foo pm remove-user 10 stat /data/misc/vold/user_keys/ce/10 # no longer exists Change-Id: Id4033a668fa6de1debb9ba6fdd1351c940bd35fc --- FsCrypt.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FsCrypt.cpp b/FsCrypt.cpp index 04def5c..765073d 100644 --- a/FsCrypt.cpp +++ b/FsCrypt.cpp @@ -569,9 +569,12 @@ bool fscrypt_destroy_user_key(userid_t user_id) { if (it != s_ephemeral_users.end()) { s_ephemeral_users.erase(it); } else { - for (auto const path : get_ce_key_paths(get_ce_key_directory_path(user_id))) { + auto ce_path = get_ce_key_directory_path(user_id); + for (auto const path : get_ce_key_paths(ce_path)) { success &= android::vold::destroyKey(path); } + success &= destroy_dir(ce_path); + auto de_key_path = get_de_key_path(user_id); if (android::vold::pathExists(de_key_path)) { success &= android::vold::destroyKey(de_key_path);