Loading cmds/installd/commands.cpp +36 −23 Original line number Original line Diff line number Diff line Loading @@ -173,35 +173,43 @@ static bool unlink_reference_profile(const char* pkgname) { return true; return true; } } static bool unlink_current_profiles(const char* pkgname) { static bool unlink_current_profile(const char* pkgname, userid_t user) { bool success = true; std::vector<userid_t> users = get_known_users(/*volume_uuid*/ nullptr); for (auto user : users) { std::string profile_dir = create_data_user_profile_package_path(user, pkgname); std::string profile_dir = create_data_user_profile_package_path(user, pkgname); std::string profile = create_primary_profile(profile_dir); std::string profile = create_primary_profile(profile_dir); if (unlink(profile.c_str()) != 0) { if (unlink(profile.c_str()) != 0) { if (errno != ENOENT) { if (errno != ENOENT) { PLOG(WARNING) << "Could not unlink " << profile; PLOG(WARNING) << "Could not unlink " << profile; success = false; return false; } } } } return true; } static bool unlink_current_profiles(const char* pkgname) { bool success = true; std::vector<userid_t> users = get_known_users(/*volume_uuid*/ nullptr); for (auto user : users) { success &= unlink_current_profile(pkgname, user); } } return success; return success; } } static bool unlink_all_profiles(const char* pkgname) { int clear_app_profiles(const char* pkgname) { bool success = true; bool success = true; success &= unlink_reference_profile(pkgname); success &= unlink_reference_profile(pkgname); success &= unlink_current_profiles(pkgname); success &= unlink_current_profiles(pkgname); return success; return success ? 0 : -1; } } int clear_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags) { int clear_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags) { std::string suffix = ""; std::string suffix = ""; bool only_cache = false; if (flags & FLAG_CLEAR_CACHE_ONLY) { if (flags & FLAG_CLEAR_CACHE_ONLY) { suffix = CACHE_DIR_POSTFIX; suffix = CACHE_DIR_POSTFIX; only_cache = true; } else if (flags & FLAG_CLEAR_CODE_CACHE_ONLY) { } else if (flags & FLAG_CLEAR_CODE_CACHE_ONLY) { suffix = CODE_CACHE_DIR_POSTFIX; suffix = CODE_CACHE_DIR_POSTFIX; only_cache = true; } } int res = 0; int res = 0; Loading @@ -217,17 +225,27 @@ int clear_app_data(const char *uuid, const char *pkgname, userid_t userid, int f // TODO: include result once 25796509 is fixed // TODO: include result once 25796509 is fixed delete_dir_contents(path); delete_dir_contents(path); } } unlink_all_profiles(pkgname); if (!only_cache) { if (!unlink_current_profile(pkgname, userid)) { res |= -1; } } } } return res; return res; } } static int destroy_app_profiles(const char *pkgname, userid_t userid) { static int destroy_app_current_profiles(const char *pkgname, userid_t userid) { // TODO: this doesn't destroy the marks for foreign dex use yet. return delete_dir_contents_and_dir(create_data_user_profile_package_path(userid, pkgname)); int res = 0; } res |= delete_dir_contents_and_dir(create_data_user_profile_package_path( userid, pkgname)); res |= delete_dir_contents_and_dir(create_data_ref_profile_package_path(pkgname)); int destroy_app_profiles(const char *pkgname) { return res; int result = 0; std::vector<userid_t> users = get_known_users(/*volume_uuid*/ nullptr); for (auto user : users) { result |= destroy_app_current_profiles(pkgname, user); } result |= delete_dir_contents_and_dir(create_data_ref_profile_package_path(pkgname)); return result; } } int destroy_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags) { int destroy_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags) { Loading @@ -239,8 +257,8 @@ int destroy_app_data(const char *uuid, const char *pkgname, userid_t userid, int if (flags & FLAG_STORAGE_DE) { if (flags & FLAG_STORAGE_DE) { res |= delete_dir_contents_and_dir( res |= delete_dir_contents_and_dir( create_data_user_de_package_path(uuid, userid, pkgname)); create_data_user_de_package_path(uuid, userid, pkgname)); res |= destroy_app_profiles(pkgname, userid); } } destroy_app_current_profiles(pkgname, userid); return res; return res; } } Loading Loading @@ -1780,11 +1798,6 @@ int rm_package_dir(const char* apk_path) return delete_dir_contents(apk_path, 1 /* also_delete_dir */ , NULL /* exclusion_predicate */); return delete_dir_contents(apk_path, 1 /* also_delete_dir */ , NULL /* exclusion_predicate */); } } int rm_profiles(const char* pkgname) { return unlink_all_profiles(pkgname) ? 0 : -1; } int link_file(const char* relative_path, const char* from_base, const char* to_base) { int link_file(const char* relative_path, const char* from_base, const char* to_base) { char from_path[PKG_PATH_MAX]; char from_path[PKG_PATH_MAX]; char to_path[PKG_PATH_MAX]; char to_path[PKG_PATH_MAX]; Loading cmds/installd/commands.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -59,7 +59,8 @@ int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int u int idmap(const char *target_path, const char *overlay_path, uid_t uid); int idmap(const char *target_path, const char *overlay_path, uid_t uid); int create_oat_dir(const char* oat_dir, const char *instruction_set); int create_oat_dir(const char* oat_dir, const char *instruction_set); int rm_package_dir(const char* apk_path); int rm_package_dir(const char* apk_path); int rm_profiles(const char* pkgname); int clear_app_profiles(const char* pkgname); int destroy_app_profiles(const char* pkgname); int link_file(const char *relative_path, const char *from_base, const char *to_base); int link_file(const char *relative_path, const char *from_base, const char *to_base); // Move a B version over to the A location. Only works for oat_dir != nullptr. // Move a B version over to the A location. Only works for oat_dir != nullptr. Loading cmds/installd/installd.cpp +10 −3 Original line number Original line Diff line number Diff line Loading @@ -358,10 +358,16 @@ static int do_rm_package_dir(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) return rm_package_dir(arg[0]); return rm_package_dir(arg[0]); } } static int do_rm_profiles(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) static int do_clear_app_profiles(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { { /* package_name */ /* package_name */ return rm_profiles(arg[0]); return clear_app_profiles(arg[0]); } static int do_destroy_app_profiles(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { /* package_name */ return destroy_app_profiles(arg[0]); } } static int do_link_file(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) static int do_link_file(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) Loading Loading @@ -402,7 +408,8 @@ struct cmdinfo cmds[] = { { "idmap", 3, do_idmap }, { "idmap", 3, do_idmap }, { "createoatdir", 2, do_create_oat_dir }, { "createoatdir", 2, do_create_oat_dir }, { "rmpackagedir", 1, do_rm_package_dir }, { "rmpackagedir", 1, do_rm_package_dir }, { "rmprofiles", 1, do_rm_profiles }, { "clear_app_profiles", 1, do_clear_app_profiles }, { "destroy_app_profiles", 1, do_destroy_app_profiles }, { "linkfile", 3, do_link_file }, { "linkfile", 3, do_link_file }, { "move_ab", 3, do_move_ab }, { "move_ab", 3, do_move_ab }, { "merge_profiles", 2, do_merge_profiles }, { "merge_profiles", 2, do_merge_profiles }, Loading Loading
cmds/installd/commands.cpp +36 −23 Original line number Original line Diff line number Diff line Loading @@ -173,35 +173,43 @@ static bool unlink_reference_profile(const char* pkgname) { return true; return true; } } static bool unlink_current_profiles(const char* pkgname) { static bool unlink_current_profile(const char* pkgname, userid_t user) { bool success = true; std::vector<userid_t> users = get_known_users(/*volume_uuid*/ nullptr); for (auto user : users) { std::string profile_dir = create_data_user_profile_package_path(user, pkgname); std::string profile_dir = create_data_user_profile_package_path(user, pkgname); std::string profile = create_primary_profile(profile_dir); std::string profile = create_primary_profile(profile_dir); if (unlink(profile.c_str()) != 0) { if (unlink(profile.c_str()) != 0) { if (errno != ENOENT) { if (errno != ENOENT) { PLOG(WARNING) << "Could not unlink " << profile; PLOG(WARNING) << "Could not unlink " << profile; success = false; return false; } } } } return true; } static bool unlink_current_profiles(const char* pkgname) { bool success = true; std::vector<userid_t> users = get_known_users(/*volume_uuid*/ nullptr); for (auto user : users) { success &= unlink_current_profile(pkgname, user); } } return success; return success; } } static bool unlink_all_profiles(const char* pkgname) { int clear_app_profiles(const char* pkgname) { bool success = true; bool success = true; success &= unlink_reference_profile(pkgname); success &= unlink_reference_profile(pkgname); success &= unlink_current_profiles(pkgname); success &= unlink_current_profiles(pkgname); return success; return success ? 0 : -1; } } int clear_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags) { int clear_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags) { std::string suffix = ""; std::string suffix = ""; bool only_cache = false; if (flags & FLAG_CLEAR_CACHE_ONLY) { if (flags & FLAG_CLEAR_CACHE_ONLY) { suffix = CACHE_DIR_POSTFIX; suffix = CACHE_DIR_POSTFIX; only_cache = true; } else if (flags & FLAG_CLEAR_CODE_CACHE_ONLY) { } else if (flags & FLAG_CLEAR_CODE_CACHE_ONLY) { suffix = CODE_CACHE_DIR_POSTFIX; suffix = CODE_CACHE_DIR_POSTFIX; only_cache = true; } } int res = 0; int res = 0; Loading @@ -217,17 +225,27 @@ int clear_app_data(const char *uuid, const char *pkgname, userid_t userid, int f // TODO: include result once 25796509 is fixed // TODO: include result once 25796509 is fixed delete_dir_contents(path); delete_dir_contents(path); } } unlink_all_profiles(pkgname); if (!only_cache) { if (!unlink_current_profile(pkgname, userid)) { res |= -1; } } } } return res; return res; } } static int destroy_app_profiles(const char *pkgname, userid_t userid) { static int destroy_app_current_profiles(const char *pkgname, userid_t userid) { // TODO: this doesn't destroy the marks for foreign dex use yet. return delete_dir_contents_and_dir(create_data_user_profile_package_path(userid, pkgname)); int res = 0; } res |= delete_dir_contents_and_dir(create_data_user_profile_package_path( userid, pkgname)); res |= delete_dir_contents_and_dir(create_data_ref_profile_package_path(pkgname)); int destroy_app_profiles(const char *pkgname) { return res; int result = 0; std::vector<userid_t> users = get_known_users(/*volume_uuid*/ nullptr); for (auto user : users) { result |= destroy_app_current_profiles(pkgname, user); } result |= delete_dir_contents_and_dir(create_data_ref_profile_package_path(pkgname)); return result; } } int destroy_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags) { int destroy_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags) { Loading @@ -239,8 +257,8 @@ int destroy_app_data(const char *uuid, const char *pkgname, userid_t userid, int if (flags & FLAG_STORAGE_DE) { if (flags & FLAG_STORAGE_DE) { res |= delete_dir_contents_and_dir( res |= delete_dir_contents_and_dir( create_data_user_de_package_path(uuid, userid, pkgname)); create_data_user_de_package_path(uuid, userid, pkgname)); res |= destroy_app_profiles(pkgname, userid); } } destroy_app_current_profiles(pkgname, userid); return res; return res; } } Loading Loading @@ -1780,11 +1798,6 @@ int rm_package_dir(const char* apk_path) return delete_dir_contents(apk_path, 1 /* also_delete_dir */ , NULL /* exclusion_predicate */); return delete_dir_contents(apk_path, 1 /* also_delete_dir */ , NULL /* exclusion_predicate */); } } int rm_profiles(const char* pkgname) { return unlink_all_profiles(pkgname) ? 0 : -1; } int link_file(const char* relative_path, const char* from_base, const char* to_base) { int link_file(const char* relative_path, const char* from_base, const char* to_base) { char from_path[PKG_PATH_MAX]; char from_path[PKG_PATH_MAX]; char to_path[PKG_PATH_MAX]; char to_path[PKG_PATH_MAX]; Loading
cmds/installd/commands.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -59,7 +59,8 @@ int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int u int idmap(const char *target_path, const char *overlay_path, uid_t uid); int idmap(const char *target_path, const char *overlay_path, uid_t uid); int create_oat_dir(const char* oat_dir, const char *instruction_set); int create_oat_dir(const char* oat_dir, const char *instruction_set); int rm_package_dir(const char* apk_path); int rm_package_dir(const char* apk_path); int rm_profiles(const char* pkgname); int clear_app_profiles(const char* pkgname); int destroy_app_profiles(const char* pkgname); int link_file(const char *relative_path, const char *from_base, const char *to_base); int link_file(const char *relative_path, const char *from_base, const char *to_base); // Move a B version over to the A location. Only works for oat_dir != nullptr. // Move a B version over to the A location. Only works for oat_dir != nullptr. Loading
cmds/installd/installd.cpp +10 −3 Original line number Original line Diff line number Diff line Loading @@ -358,10 +358,16 @@ static int do_rm_package_dir(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) return rm_package_dir(arg[0]); return rm_package_dir(arg[0]); } } static int do_rm_profiles(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) static int do_clear_app_profiles(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { { /* package_name */ /* package_name */ return rm_profiles(arg[0]); return clear_app_profiles(arg[0]); } static int do_destroy_app_profiles(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) { /* package_name */ return destroy_app_profiles(arg[0]); } } static int do_link_file(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) static int do_link_file(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) Loading Loading @@ -402,7 +408,8 @@ struct cmdinfo cmds[] = { { "idmap", 3, do_idmap }, { "idmap", 3, do_idmap }, { "createoatdir", 2, do_create_oat_dir }, { "createoatdir", 2, do_create_oat_dir }, { "rmpackagedir", 1, do_rm_package_dir }, { "rmpackagedir", 1, do_rm_package_dir }, { "rmprofiles", 1, do_rm_profiles }, { "clear_app_profiles", 1, do_clear_app_profiles }, { "destroy_app_profiles", 1, do_destroy_app_profiles }, { "linkfile", 3, do_link_file }, { "linkfile", 3, do_link_file }, { "move_ab", 3, do_move_ab }, { "move_ab", 3, do_move_ab }, { "merge_profiles", 2, do_merge_profiles }, { "merge_profiles", 2, do_merge_profiles }, Loading