am cd620591: Merge "installd: fix forward locking symlink" into jb-mr1-dev

* commit 'cd620591b764cd999f18878985444fba01d5b710':
  installd: fix forward locking symlink
This commit is contained in:
Nick Kralevich
2012-09-07 16:17:16 -07:00
committed by Android Git Automerger
3 changed files with 21 additions and 8 deletions

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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());