diff options
Diffstat (limited to 'cmds/installd/commands.c')
-rw-r--r-- | cmds/installd/commands.c | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c index fc3972e..0a307c9 100644 --- a/cmds/installd/commands.c +++ b/cmds/installd/commands.c @@ -144,7 +144,6 @@ int fix_uid(const char *pkgname, uid_t uid, gid_t gid) { char pkgdir[PKG_PATH_MAX]; struct stat s; - int rc = 0; if ((uid < AID_SYSTEM) || (gid < AID_SYSTEM)) { ALOGE("invalid uid/gid: %d %d\n", uid, gid); @@ -646,8 +645,40 @@ static void run_dexopt(int zip_fd, int odex_fd, const char* input_file_name, ALOGE("execl(%s) failed: %s\n", DEX_OPT_BIN, strerror(errno)); } +static int split_count(const char *str) +{ + char *ctx; + int count = 0; + char buf[PROPERTY_VALUE_MAX]; + + strncpy(buf, str, sizeof(buf)); + char *pBuf = buf; + + while(strtok_r(pBuf, " ", &ctx) != NULL) { + count++; + pBuf = NULL; + } + + return count; +} + +static int split(char *buf, char **argv) +{ + char *ctx; + int count = 0; + char *tok; + char *pBuf = buf; + + while((tok = strtok_r(pBuf, " ", &ctx)) != NULL) { + argv[count++] = tok; + pBuf = NULL; + } + + return count; +} + static void run_patchoat(int input_fd, int oat_fd, const char* input_file_name, - const char* output_file_name, const char *pkgname, const char *instruction_set) + const char* output_file_name, const char *pkgname __unused, const char *instruction_set) { static const int MAX_INT_LEN = 12; // '-'+10dig+'\0' -OR- 0x+8dig static const unsigned int MAX_INSTRUCTION_SET_LEN = 7; @@ -669,7 +700,7 @@ static void run_patchoat(int input_fd, int oat_fd, const char* input_file_name, sprintf(instruction_set_arg, "--instruction-set=%s", instruction_set); sprintf(output_oat_fd_arg, "--output-oat-fd=%d", oat_fd); sprintf(input_oat_fd_arg, "--input-oat-fd=%d", input_fd); - ALOGE("Running %s isa=%s in-fd=%d (%s) out-fd=%d (%s)\n", + ALOGV("Running %s isa=%s in-fd=%d (%s) out-fd=%d (%s)\n", PATCHOAT_BIN, instruction_set, input_fd, input_file_name, oat_fd, output_file_name); /* patchoat, patched-image-location, no-lock, isa, input-fd, output-fd */ @@ -718,7 +749,8 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name, dex2oat_isa_features, NULL) > 0; char dex2oat_flags[PROPERTY_VALUE_MAX]; - bool have_dex2oat_flags = property_get("dalvik.vm.dex2oat-flags", dex2oat_flags, NULL) > 0; + int dex2oat_flags_count = property_get("dalvik.vm.dex2oat-flags", + dex2oat_flags, NULL) <= 0 ? 0 : split_count(dex2oat_flags); ALOGV("dalvik.vm.dex2oat-flags=%s\n", dex2oat_flags); // If we booting without the real /data, don't spend time compiling. @@ -796,7 +828,7 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name, + (have_dex2oat_Xms_flag ? 2 : 0) + (have_dex2oat_Xmx_flag ? 2 : 0) + (have_dex2oat_compiler_filter_flag ? 1 : 0) - + (have_dex2oat_flags ? 1 : 0)]; + + dex2oat_flags_count]; int i = 0; argv[i++] = (char*)DEX2OAT_BIN; argv[i++] = zip_fd_arg; @@ -824,14 +856,14 @@ static void run_dex2oat(int zip_fd, int oat_fd, const char* input_file_name, if (have_dex2oat_compiler_filter_flag) { argv[i++] = dex2oat_compiler_filter_arg; } - if (have_dex2oat_flags) { - argv[i++] = dex2oat_flags; + if (dex2oat_flags_count) { + i += split(dex2oat_flags, argv + i); } // Do not add after dex2oat_flags, they should override others for debugging. argv[i] = NULL; execv(DEX2OAT_BIN, (char* const *)argv); - ALOGE("execl(%s) failed: %s\n", DEX2OAT_BIN, strerror(errno)); + ALOGE("execv(%s) failed: %s\n", DEX2OAT_BIN, strerror(errno)); } static int wait_child(pid_t pid) @@ -1542,7 +1574,7 @@ int restorecon_data(const char* pkgName, const char* seinfo, uid_t uid) continue; } - if (selinux_android_restorecon_pkgdir(pkgdir, seinfo, uid, flags) < 0) { + if (selinux_android_restorecon_pkgdir(pkgdir, seinfo, s.st_uid, flags) < 0) { ALOGE("restorecon failed for %s: %s\n", pkgdir, strerror(errno)); ret |= -1; } |