summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2012-09-07 15:58:43 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-07 15:58:44 -0700
commitcd620591b764cd999f18878985444fba01d5b710 (patch)
tree4e5da1d1ca16e8e45e5e89d5b6123b3f98a418a8
parent1275abd013eee87b3fec5b704a799440cb1c71fe (diff)
parent7de350a91301985b7f2d9f28edde5aade8495d9b (diff)
downloadframeworks_base-cd620591b764cd999f18878985444fba01d5b710.zip
frameworks_base-cd620591b764cd999f18878985444fba01d5b710.tar.gz
frameworks_base-cd620591b764cd999f18878985444fba01d5b710.tar.bz2
Merge "installd: fix forward locking symlink" into jb-mr1-dev
-rw-r--r--cmds/installd/commands.c14
-rwxr-xr-xcore/tests/coretests/src/android/content/pm/PackageManagerTests.java8
-rw-r--r--services/java/com/android/server/pm/PackageManagerService.java7
3 files changed, 21 insertions, 8 deletions
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c
index 9e83a67..697d8ec 100644
--- a/cmds/installd/commands.c
+++ b/cmds/installd/commands.c
@@ -420,7 +420,7 @@ int protect(char *pkgname, gid_t gid)
return -1;
}
if (chmod(pkgpath, S_IRUSR|S_IWUSR|S_IRGRP) < 0) {
- ALOGE("failed to chmod '%s': %s\n", pkgpath, strerror(errno));
+ ALOGE("protect(): failed to chmod '%s': %s\n", pkgpath, strerror(errno));
return -1;
}
@@ -1014,13 +1014,13 @@ int linklib(const char* dataDir, const char* asecLibDir)
if (stat(dataDir, &s) < 0) return -1;
- if (chown(dataDir, 0, 0) < 0) {
+ if (chown(dataDir, AID_INSTALL, AID_INSTALL) < 0) {
ALOGE("failed to chown '%s': %s\n", dataDir, strerror(errno));
return -1;
}
if (chmod(dataDir, 0700) < 0) {
- ALOGE("failed to chmod '%s': %s\n", dataDir, strerror(errno));
+ ALOGE("linklib() 1: failed to chmod '%s': %s\n", dataDir, strerror(errno));
rc = -1;
goto out;
}
@@ -1058,7 +1058,7 @@ int linklib(const char* dataDir, const char* asecLibDir)
out:
if (chmod(dataDir, s.st_mode) < 0) {
- ALOGE("failed to chmod '%s': %s\n", dataDir, strerror(errno));
+ ALOGE("linklib() 2: failed to chmod '%s': %s\n", dataDir, strerror(errno));
rc = -errno;
}
@@ -1091,13 +1091,13 @@ int unlinklib(const char* dataDir)
return -1;
}
- if (chown(dataDir, 0, 0) < 0) {
+ if (chown(dataDir, AID_INSTALL, AID_INSTALL) < 0) {
ALOGE("failed to chown '%s': %s\n", dataDir, strerror(errno));
return -1;
}
if (chmod(dataDir, 0700) < 0) {
- ALOGE("failed to chmod '%s': %s\n", dataDir, strerror(errno));
+ ALOGE("unlinklib() 1: failed to chmod '%s': %s\n", dataDir, strerror(errno));
rc = -1;
goto out;
}
@@ -1140,7 +1140,7 @@ int unlinklib(const char* dataDir)
out:
if (chmod(dataDir, s.st_mode) < 0) {
- ALOGE("failed to chmod '%s': %s\n", dataDir, strerror(errno));
+ ALOGE("unlinklib() 2: failed to chmod '%s': %s\n", dataDir, strerror(errno));
rc = -1;
}
diff --git a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
index a1fd14e..607150a 100755
--- a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
+++ b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
@@ -395,6 +395,14 @@ public class PackageManagerTests extends AndroidTestCase {
assertTrue("The native library path (" + info.nativeLibraryDir
+ ") should start with " + SECURE_CONTAINERS_PREFIX,
info.nativeLibraryDir.startsWith(SECURE_CONTAINERS_PREFIX));
+ try {
+ String compatLib = new File(info.dataDir + "/lib").getCanonicalPath();
+ assertEquals("The compatibility lib directory should be a symbolic link to "
+ + info.nativeLibraryDir,
+ info.nativeLibraryDir, compatLib);
+ } catch (IOException e) {
+ fail("compat check: Can't read " + info.dataDir + "/lib");
+ }
} else {
assertFalse((info.flags & ApplicationInfo.FLAG_FORWARD_LOCK) != 0);
assertEquals(srcPath, appInstallPath);
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index 7a27f7d..133d926 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -4110,8 +4110,13 @@ public class PackageManagerService extends IPackageManager.Stub {
NativeLibraryHelper.copyNativeBinariesIfNeededLI(scanFile, nativeLibraryDir);
} else {
Slog.i(TAG, "Linking native library dir for " + path);
- mInstaller.linkNativeLibraryDirectory(dataPathString,
+ int ret = mInstaller.linkNativeLibraryDirectory(dataPathString,
pkg.applicationInfo.nativeLibraryDir);
+ if (ret < 0) {
+ Slog.w(TAG, "Failed linking native library dir for " + path);
+ mLastScanError = PackageManager.MOVE_FAILED_INSUFFICIENT_STORAGE;
+ return null;
+ }
}
} catch (IOException ioe) {
Log.e(TAG, "Unable to get canonical file " + ioe.toString());