diff options
Diffstat (limited to 'cmds/installd/commands.c')
-rw-r--r-- | cmds/installd/commands.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c index d94daf7..c16e6fb 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; } @@ -412,7 +432,7 @@ int protect(char *pkgname, gid_t gid) return 0; } -int get_size(const char *pkgname, const char *apkpath, +int get_size(const char *pkgname, int persona, const char *apkpath, const char *fwdlock_apkpath, const char *asecpath, int64_t *_codesize, int64_t *_datasize, int64_t *_cachesize, int64_t* _asecsize) @@ -459,7 +479,7 @@ int get_size(const char *pkgname, const char *apkpath, } } - if (create_pkg_path(path, pkgname, PKG_DIR_POSTFIX, 0)) { + if (create_pkg_path(path, pkgname, PKG_DIR_POSTFIX, persona)) { goto done; } |