Loading cmds/installd/commands.c +15 −5 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ /* Directory records that are used in execution of commands. */ dir_rec_t android_data_dir; dir_rec_t android_datadata_dir; dir_rec_t android_asec_dir; dir_rec_t android_app_dir; dir_rec_t android_app_private_dir; Loading Loading @@ -184,7 +185,7 @@ int delete_user_data(const char *pkgname, uid_t persona) return delete_dir_contents(pkgdir, 0, "lib"); } int make_user_data(const char *pkgname, uid_t uid, uid_t persona) int make_user_data(const char *pkgname, uid_t uid, uid_t persona, const char* seinfo) { char pkgdir[PKG_PATH_MAX]; char applibdir[PKG_PATH_MAX]; Loading Loading @@ -245,7 +246,7 @@ int make_user_data(const char *pkgname, uid_t uid, uid_t persona) return -1; } if (selinux_android_setfilecon(pkgdir, pkgname, uid) < 0) { if (selinux_android_setfilecon2(pkgdir, pkgname, seinfo, uid) < 0) { ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno)); unlink(libsymlink); unlink(pkgdir); Loading Loading @@ -546,6 +547,7 @@ int create_cache_path(char path[PKG_PATH_MAX], const char *src) char *tmp; int srclen; int dstlen; char dexopt_data_only[PROPERTY_VALUE_MAX]; srclen = strlen(src); Loading @@ -558,7 +560,15 @@ int create_cache_path(char path[PKG_PATH_MAX], const char *src) return -1; } dstlen = srclen + strlen(DALVIK_CACHE_PREFIX) + const char *cache_path = DALVIK_CACHE_PREFIX; if (!strncmp(src, "/system", 7)) { property_get("dalvik.vm.dexopt-data-only", dexopt_data_only, ""); if (strcmp(dexopt_data_only, "1") != 0) { cache_path = DALVIK_SYSTEM_CACHE_PREFIX; } } dstlen = srclen + strlen(cache_path) + strlen(DALVIK_CACHE_POSTFIX) + 1; if (dstlen > PKG_PATH_MAX) { Loading @@ -566,11 +576,11 @@ int create_cache_path(char path[PKG_PATH_MAX], const char *src) } sprintf(path,"%s%s%s", DALVIK_CACHE_PREFIX, cache_path, src + 1, /* skip the leading / */ DALVIK_CACHE_POSTFIX); for(tmp = path + strlen(DALVIK_CACHE_PREFIX); *tmp; tmp++) { for(tmp = path + strlen(cache_path); *tmp; tmp++) { if (*tmp == '/') { *tmp = '@'; } Loading cmds/installd/installd.c +8 −2 Original line number Diff line number Diff line Loading @@ -103,7 +103,8 @@ static int do_rm_user_data(char **arg, char reply[REPLY_MAX]) static int do_mk_user_data(char **arg, char reply[REPLY_MAX]) { return make_user_data(arg[0], atoi(arg[1]), atoi(arg[2])); /* pkgname, uid, userid */ return make_user_data(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3]); /* pkgname, uid, userid, seinfo */ } static int do_rm_user(char **arg, char reply[REPLY_MAX]) Loading Loading @@ -142,7 +143,7 @@ struct cmdinfo cmds[] = { { "rmuserdata", 2, do_rm_user_data }, { "movefiles", 0, do_movefiles }, { "linklib", 3, do_linklib }, { "mkuserdata", 3, do_mk_user_data }, { "mkuserdata", 4, do_mk_user_data }, { "rmuser", 1, do_rm_user }, }; Loading Loading @@ -268,6 +269,11 @@ int initialize_globals() { return -1; } // Get the android datadata directory. if (copy_and_append(&android_datadata_dir, &android_data_dir, DATA_SUBDIR) < 0) { return -1; } // Get the android app directory. if (copy_and_append(&android_app_dir, &android_data_dir, APP_SUBDIR) < 0) { return -1; Loading cmds/installd/installd.h +5 −1 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ #define CACHE_DIR_POSTFIX "/cache" #define DATA_SUBDIR "data/" // sub-directory under ANDROID_DATA #define APP_SUBDIR "app/" // sub-directory under ANDROID_DATA #define APP_LIB_SUBDIR "app-lib/" // sub-directory under ANDROID_DATA Loading @@ -72,6 +74,7 @@ #define DALVIK_CACHE_PREFIX "/data/dalvik-cache/" #define DALVIK_CACHE_POSTFIX "/classes.dex" #define DALVIK_SYSTEM_CACHE_PREFIX "/cache/dalvik-cache/" #define UPDATE_COMMANDS_DIR_PREFIX "/system/etc/updatecmds/" Loading @@ -97,6 +100,7 @@ extern dir_rec_t android_app_dir; extern dir_rec_t android_app_private_dir; extern dir_rec_t android_app_lib_dir; extern dir_rec_t android_data_dir; extern dir_rec_t android_datadata_dir; extern dir_rec_t android_asec_dir; extern dir_rec_t android_media_dir; extern dir_rec_array_t android_system_dirs; Loading Loading @@ -197,7 +201,7 @@ int uninstall(const char *pkgname, uid_t persona); int renamepkg(const char *oldpkgname, const char *newpkgname); int fix_uid(const char *pkgname, uid_t uid, gid_t gid); int delete_user_data(const char *pkgname, uid_t persona); int make_user_data(const char *pkgname, uid_t uid, uid_t persona); int make_user_data(const char *pkgname, uid_t uid, uid_t persona, const char* seinfo); int delete_persona(uid_t persona); int delete_cache(const char *pkgname, uid_t persona); int move_dex(const char *src, const char *dst); Loading cmds/installd/utils.c +5 −1 Original line number Diff line number Diff line Loading @@ -362,7 +362,11 @@ int lookup_media_dir(char basepath[PATH_MAX], const char *dir) int64_t data_disk_free() { struct statfs sfs; if (statfs(android_data_dir.path, &sfs) == 0) { /* Scanning /data/data because on some devices, it's on a different partition * and scanning /data will yield the incorrect result. (This function is only * used for freeing space on /data/data so it is okay to be more specific.) */ if (statfs(android_datadata_dir.path, &sfs) == 0) { return sfs.f_bavail * sfs.f_bsize; } else { ALOGE("Couldn't statfs %s: %s\n", android_data_dir.path, strerror(errno)); Loading Loading
cmds/installd/commands.c +15 −5 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ /* Directory records that are used in execution of commands. */ dir_rec_t android_data_dir; dir_rec_t android_datadata_dir; dir_rec_t android_asec_dir; dir_rec_t android_app_dir; dir_rec_t android_app_private_dir; Loading Loading @@ -184,7 +185,7 @@ int delete_user_data(const char *pkgname, uid_t persona) return delete_dir_contents(pkgdir, 0, "lib"); } int make_user_data(const char *pkgname, uid_t uid, uid_t persona) int make_user_data(const char *pkgname, uid_t uid, uid_t persona, const char* seinfo) { char pkgdir[PKG_PATH_MAX]; char applibdir[PKG_PATH_MAX]; Loading Loading @@ -245,7 +246,7 @@ int make_user_data(const char *pkgname, uid_t uid, uid_t persona) return -1; } if (selinux_android_setfilecon(pkgdir, pkgname, uid) < 0) { if (selinux_android_setfilecon2(pkgdir, pkgname, seinfo, uid) < 0) { ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno)); unlink(libsymlink); unlink(pkgdir); Loading Loading @@ -546,6 +547,7 @@ int create_cache_path(char path[PKG_PATH_MAX], const char *src) char *tmp; int srclen; int dstlen; char dexopt_data_only[PROPERTY_VALUE_MAX]; srclen = strlen(src); Loading @@ -558,7 +560,15 @@ int create_cache_path(char path[PKG_PATH_MAX], const char *src) return -1; } dstlen = srclen + strlen(DALVIK_CACHE_PREFIX) + const char *cache_path = DALVIK_CACHE_PREFIX; if (!strncmp(src, "/system", 7)) { property_get("dalvik.vm.dexopt-data-only", dexopt_data_only, ""); if (strcmp(dexopt_data_only, "1") != 0) { cache_path = DALVIK_SYSTEM_CACHE_PREFIX; } } dstlen = srclen + strlen(cache_path) + strlen(DALVIK_CACHE_POSTFIX) + 1; if (dstlen > PKG_PATH_MAX) { Loading @@ -566,11 +576,11 @@ int create_cache_path(char path[PKG_PATH_MAX], const char *src) } sprintf(path,"%s%s%s", DALVIK_CACHE_PREFIX, cache_path, src + 1, /* skip the leading / */ DALVIK_CACHE_POSTFIX); for(tmp = path + strlen(DALVIK_CACHE_PREFIX); *tmp; tmp++) { for(tmp = path + strlen(cache_path); *tmp; tmp++) { if (*tmp == '/') { *tmp = '@'; } Loading
cmds/installd/installd.c +8 −2 Original line number Diff line number Diff line Loading @@ -103,7 +103,8 @@ static int do_rm_user_data(char **arg, char reply[REPLY_MAX]) static int do_mk_user_data(char **arg, char reply[REPLY_MAX]) { return make_user_data(arg[0], atoi(arg[1]), atoi(arg[2])); /* pkgname, uid, userid */ return make_user_data(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3]); /* pkgname, uid, userid, seinfo */ } static int do_rm_user(char **arg, char reply[REPLY_MAX]) Loading Loading @@ -142,7 +143,7 @@ struct cmdinfo cmds[] = { { "rmuserdata", 2, do_rm_user_data }, { "movefiles", 0, do_movefiles }, { "linklib", 3, do_linklib }, { "mkuserdata", 3, do_mk_user_data }, { "mkuserdata", 4, do_mk_user_data }, { "rmuser", 1, do_rm_user }, }; Loading Loading @@ -268,6 +269,11 @@ int initialize_globals() { return -1; } // Get the android datadata directory. if (copy_and_append(&android_datadata_dir, &android_data_dir, DATA_SUBDIR) < 0) { return -1; } // Get the android app directory. if (copy_and_append(&android_app_dir, &android_data_dir, APP_SUBDIR) < 0) { return -1; Loading
cmds/installd/installd.h +5 −1 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ #define CACHE_DIR_POSTFIX "/cache" #define DATA_SUBDIR "data/" // sub-directory under ANDROID_DATA #define APP_SUBDIR "app/" // sub-directory under ANDROID_DATA #define APP_LIB_SUBDIR "app-lib/" // sub-directory under ANDROID_DATA Loading @@ -72,6 +74,7 @@ #define DALVIK_CACHE_PREFIX "/data/dalvik-cache/" #define DALVIK_CACHE_POSTFIX "/classes.dex" #define DALVIK_SYSTEM_CACHE_PREFIX "/cache/dalvik-cache/" #define UPDATE_COMMANDS_DIR_PREFIX "/system/etc/updatecmds/" Loading @@ -97,6 +100,7 @@ extern dir_rec_t android_app_dir; extern dir_rec_t android_app_private_dir; extern dir_rec_t android_app_lib_dir; extern dir_rec_t android_data_dir; extern dir_rec_t android_datadata_dir; extern dir_rec_t android_asec_dir; extern dir_rec_t android_media_dir; extern dir_rec_array_t android_system_dirs; Loading Loading @@ -197,7 +201,7 @@ int uninstall(const char *pkgname, uid_t persona); int renamepkg(const char *oldpkgname, const char *newpkgname); int fix_uid(const char *pkgname, uid_t uid, gid_t gid); int delete_user_data(const char *pkgname, uid_t persona); int make_user_data(const char *pkgname, uid_t uid, uid_t persona); int make_user_data(const char *pkgname, uid_t uid, uid_t persona, const char* seinfo); int delete_persona(uid_t persona); int delete_cache(const char *pkgname, uid_t persona); int move_dex(const char *src, const char *dst); Loading
cmds/installd/utils.c +5 −1 Original line number Diff line number Diff line Loading @@ -362,7 +362,11 @@ int lookup_media_dir(char basepath[PATH_MAX], const char *dir) int64_t data_disk_free() { struct statfs sfs; if (statfs(android_data_dir.path, &sfs) == 0) { /* Scanning /data/data because on some devices, it's on a different partition * and scanning /data will yield the incorrect result. (This function is only * used for freeing space on /data/data so it is okay to be more specific.) */ if (statfs(android_datadata_dir.path, &sfs) == 0) { return sfs.f_bavail * sfs.f_bsize; } else { ALOGE("Couldn't statfs %s: %s\n", android_data_dir.path, strerror(errno)); Loading