summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorRicardo Cerqueira <ricardo@cyngn.com>2015-10-30 18:36:57 +0000
committerRicardo Cerqueira <ricardo@cyngn.com>2015-10-30 18:36:57 +0000
commitd15d2252b026322317a584ccbcc8b0c05b7d6d7f (patch)
tree9b6e76ee3b47aa4eb858094f1d7f7ec063740954 /cmds
parent716c2cf34abd1df52210cb0aca6003b4d444a7ac (diff)
downloadframeworks_native-d15d2252b026322317a584ccbcc8b0c05b7d6d7f.zip
frameworks_native-d15d2252b026322317a584ccbcc8b0c05b7d6d7f.tar.gz
frameworks_native-d15d2252b026322317a584ccbcc8b0c05b7d6d7f.tar.bz2
installd: Run all of the appt setup operations in the child process
Change-Id: Ifc18741380d7f922540d04ef622f17edfd87dbdf
Diffstat (limited to 'cmds')
-rw-r--r--cmds/installd/commands.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp
index cf54598..eb7e4e5 100644
--- a/cmds/installd/commands.cpp
+++ b/cmds/installd/commands.cpp
@@ -1761,28 +1761,28 @@ int aapt(const char *source_apk, const char *internal_path, const char *out_rest
pid_t pid = fork();
- // get file descriptor for resources.arsc
- snprintf(restable_path, PATH_MAX, "%s/resources.arsc", out_restable);
- unlink(restable_path);
-
- // get file descriptor for resources.apk
- snprintf(resapk_path, PATH_MAX, "%s/resources.apk", out_restable);
- unlink(resapk_path);
- resapk_fd = open(resapk_path, O_RDWR | O_CREAT | O_EXCL, 0644);
- if (resapk_fd < 0) {
- ALOGE("aapt cannot open '%s' for output: %s\n", resapk_path, strerror(errno));
- goto fail;
- }
- if (fchown(resapk_fd, AID_SYSTEM, uid) < 0) {
- ALOGE("aapt cannot chown '%s'\n", resapk_path);
- goto fail;
- }
- if (fchmod(resapk_fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) < 0) {
- ALOGE("aapt cannot chmod '%s'\n", resapk_path);
- goto fail;
- }
-
if (pid == 0) {
+ // get file descriptor for resources.arsc
+ snprintf(restable_path, PATH_MAX, "%s/resources.arsc", out_restable);
+ unlink(restable_path);
+
+ // get file descriptor for resources.apk
+ snprintf(resapk_path, PATH_MAX, "%s/resources.apk", out_restable);
+ unlink(resapk_path);
+ resapk_fd = open(resapk_path, O_RDWR | O_CREAT | O_EXCL, 0644);
+ if (resapk_fd < 0) {
+ ALOGE("aapt cannot open '%s' for output: %s\n", resapk_path, strerror(errno));
+ goto fail;
+ }
+ if (fchown(resapk_fd, AID_SYSTEM, uid) < 0) {
+ ALOGE("aapt cannot chown '%s'\n", resapk_path);
+ goto fail;
+ }
+ if (fchmod(resapk_fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) < 0) {
+ ALOGE("aapt cannot chmod '%s'\n", resapk_path);
+ goto fail;
+ }
+
/* 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) {