installd: Run all of the appt setup operations in the child process

Change-Id: Ifc18741380d7f922540d04ef622f17edfd87dbdf
This commit is contained in:
Ricardo Cerqueira 2015-10-30 18:36:57 +00:00
parent 716c2cf34a
commit d15d2252b0
1 changed files with 22 additions and 22 deletions

View File

@ -1761,6 +1761,7 @@ int aapt(const char *source_apk, const char *internal_path, const char *out_rest
pid_t pid = fork();
if (pid == 0) {
// get file descriptor for resources.arsc
snprintf(restable_path, PATH_MAX, "%s/resources.arsc", out_restable);
unlink(restable_path);
@ -1782,7 +1783,6 @@ int aapt(const char *source_apk, const char *internal_path, const char *out_rest
goto fail;
}
if (pid == 0) {
/* child -- drop privileges before continuing */
if (setgid(uid) != 0) {
ALOGE("setgid(%d) failed during aapt\n", uid);
@ -1807,6 +1807,7 @@ int aapt(const char *source_apk, const char *internal_path, const char *out_rest
run_aapt(source_apk, internal_path, resapk_fd, pkgId, min_sdk_version, common_res_path);
close(resapk_fd);
if (pipefd[CHILD_WRITE_PIPE] > 0) {
close(pipefd[CHILD_WRITE_PIPE]);
}
@ -1845,7 +1846,6 @@ int aapt(const char *source_apk, const char *internal_path, const char *out_rest
}
}
close(resapk_fd);
return 0;
fail:
if (resapk_fd >= 0) {