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

Commit 3b2a9d22 authored by Nick Kralevich's avatar Nick Kralevich Committed by Gerrit Code Review
Browse files

Merge "Change when the SELinux relabel of /data/data occurs."

parents e3434fc4 172d38bc
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -397,7 +397,14 @@ public final class Installer {
        return execute(builder.toString());
    }

    public boolean restoreconData() {
        return (execute("restorecondata") == 0);
    public boolean restoreconData(String pkgName, String seinfo, int uid) {
        StringBuilder builder = new StringBuilder("restorecondata");
        builder.append(' ');
        builder.append(pkgName);
        builder.append(' ');
        builder.append(seinfo != null ? seinfo : "!");
        builder.append(' ');
        builder.append(uid);
        return (execute(builder.toString()) == 0);
    }
}
+12 −7
Original line number Diff line number Diff line
@@ -393,6 +393,9 @@ public class PackageManagerService extends IPackageManager.Stub {
    // If mac_permissions.xml was found for seinfo labeling.
    boolean mFoundPolicyFile;

    // If a recursive restorecon of /data/data/<pkg> is needed.
    private boolean mShouldRestoreconData = SELinuxMMAC.shouldRestorecon();

    // All available activities, for your resolving pleasure.
    final ActivityIntentResolver mActivities =
            new ActivityIntentResolver();
@@ -1486,13 +1489,6 @@ public class PackageManagerService extends IPackageManager.Stub {
            // can downgrade to reader
            mSettings.writeLPr();

            if (SELinuxMMAC.shouldRestorecon()) {
                Slog.i(TAG, "Relabeling of /data/data and /data/user issued.");
                if (mInstaller.restoreconData()) {
                    SELinuxMMAC.setRestoreconDone();
                }
            }

            EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_READY,
                    SystemClock.uptimeMillis());

@@ -4617,6 +4613,11 @@ public class PackageManagerService extends IPackageManager.Stub {
                    }
                }
                pkg.applicationInfo.dataDir = dataPath.getPath();
                if (mShouldRestoreconData) {
                    Slog.i(TAG, "SELinux relabeling of " + pkg.packageName + " issued.");
                    mInstaller.restoreconData(pkg.packageName, pkg.applicationInfo.seinfo,
                                pkg.applicationInfo.uid);
                }
            } else {
                if (DEBUG_PACKAGE_SCANNING) {
                    if ((parseFlags & PackageParser.PARSE_CHATTY) != 0)
@@ -11062,6 +11063,10 @@ public class PackageManagerService extends IPackageManager.Stub {
     */
    public void scanAvailableAsecs() {
        updateExternalMediaStatusInner(true, false, false);
        if (mShouldRestoreconData) {
            SELinuxMMAC.setRestoreconDone();
            mShouldRestoreconData = false;
        }
    }

    /*