diff options
Diffstat (limited to 'cmds/installd/commands.c')
-rw-r--r-- | cmds/installd/commands.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c index d94daf70ea3b..0a7cb2d82fbf 100644 --- a/cmds/installd/commands.c +++ b/cmds/installd/commands.c @@ -213,18 +213,30 @@ int make_user_data(const char *pkgname, uid_t uid, uid_t persona) int delete_persona(uid_t persona) { - char pkgdir[PKG_PATH_MAX]; + char data_path[PKG_PATH_MAX]; + if (create_persona_path(data_path, persona)) { + return -1; + } + if (delete_dir_contents(data_path, 1, NULL)) { + return -1; + } - if (create_persona_path(pkgdir, persona)) + char media_path[PATH_MAX]; + if (create_persona_media_path(media_path, (userid_t) persona) == -1) { + return -1; + } + if (delete_dir_contents(media_path, 1, NULL) == -1) { return -1; + } - return delete_dir_contents(pkgdir, 1, NULL); + return 0; } int clone_persona_data(uid_t src_persona, uid_t target_persona, int copy) { char src_data_dir[PKG_PATH_MAX]; char pkg_path[PKG_PATH_MAX]; + char media_path[PATH_MAX]; DIR *d; struct dirent *de; struct stat s; @@ -233,6 +245,9 @@ int clone_persona_data(uid_t src_persona, uid_t target_persona, int copy) if (create_persona_path(src_data_dir, src_persona)) { return -1; } + if (create_persona_media_path(media_path, (userid_t) target_persona) == -1) { + return -1; + } d = opendir(src_data_dir); if (d != NULL) { @@ -260,6 +275,11 @@ int clone_persona_data(uid_t src_persona, uid_t target_persona, int copy) } closedir(d); } + + // ensure /data/media/<user_id> exists + if (ensure_dir(media_path, 0770, AID_MEDIA_RW, AID_MEDIA_RW) == -1) { + return -1; + } return 0; } |