diff options
author | 2016-04-14 20:45:06 -0600 | |
---|---|---|
committer | 2016-04-15 13:35:52 -0600 | |
commit | 379a12b0072b322c7f86e690a8e8a220e500861c (patch) | |
tree | edfc822e311e563c48c49b6f76af66c2dffcbdc3 /cmds/installd/utils.cpp | |
parent | 8bf556ec85af8d4d47aad5a19a0633cf8b0fa17e (diff) |
Consistent creation/destruction of user data.
Preparing and destroying users currently needs to be split across
installd, system_server, and vold, since no single party has all the
required SELinux permissions.
Start passing down flags so we only prepare/destroy storage areas
that have keys currently installed.
Add delete_dir_contents_and_dir() argument to ignore ENOENT, since
all we care about is the directory being gone.
Bug: 27896918
Change-Id: Ia1cccc9b35e6ff09e3ca50effeab676157b856e8
Diffstat (limited to 'cmds/installd/utils.cpp')
-rw-r--r-- | cmds/installd/utils.cpp | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/cmds/installd/utils.cpp b/cmds/installd/utils.cpp index 5c2ad2dcee..90d2a9ebc3 100644 --- a/cmds/installd/utils.cpp +++ b/cmds/installd/utils.cpp @@ -193,6 +193,10 @@ std::string create_data_media_path(const char* volume_uuid, userid_t userid) { return StringPrintf("%s/media/%u", create_data_path(volume_uuid).c_str(), userid); } +std::string create_data_misc_legacy_path(userid_t userid) { + return StringPrintf("%s/misc/user/%u", create_data_path(nullptr).c_str(), userid); +} + std::string create_data_user_profiles_path(userid_t userid) { return StringPrintf("%s/cur/%u", android_profiles_dir.path, userid); } @@ -239,17 +243,6 @@ std::vector<userid_t> get_known_users(const char* volume_uuid) { return users; } -/** - * Create the path name for config for a certain userid. - * Returns 0 on success, and -1 on failure. - */ -int create_user_config_path(char path[PATH_MAX], userid_t userid) { - if (snprintf(path, PATH_MAX, "%s%d", "/data/misc/user/", userid) > PATH_MAX) { - return -1; - } - return 0; -} - int create_move_path(char path[PKG_PATH_MAX], const char* pkgname, const char* leaf, @@ -1219,19 +1212,13 @@ char *build_string3(const char *s1, const char *s2, const char *s3) { } int ensure_config_user_dirs(userid_t userid) { - char config_user_path[PATH_MAX]; - // writable by system, readable by any app within the same user const int uid = multiuser_get_uid(userid, AID_SYSTEM); const int gid = multiuser_get_uid(userid, AID_EVERYBODY); // Ensure /data/misc/user/<userid> exists - create_user_config_path(config_user_path, userid); - if (fs_prepare_dir(config_user_path, 0750, uid, gid) == -1) { - return -1; - } - - return 0; + auto path = create_data_misc_legacy_path(userid); + return fs_prepare_dir(path.c_str(), 0750, uid, gid); } int wait_child(pid_t pid) |