Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd620591 authored by Nick Kralevich's avatar Nick Kralevich Committed by Android (Google) Code Review
Browse files

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

parents 1275abd0 7de350a9
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -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;
    }

+8 −0
Original line number Diff line number Diff line
@@ -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);
+6 −1
Original line number Diff line number Diff line
@@ -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());