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

Commit a1d9f2cf authored by Martin Stjernholm's avatar Martin Stjernholm Committed by Automerger Merge Worker
Browse files

Merge "Only allow access to the dexopt commands from root or shell." into...

Merge "Only allow access to the dexopt commands from root or shell." into udc-dev am: 71498b56 am: f4c9e3bd

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21510886



Change-Id: I07b8b982861036a28abe612bc7c4f6f8b73f5384
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents d60c5d24 f4c9e3bd
Loading
Loading
Loading
Loading
+0 −8
Original line number Original line Diff line number Diff line
@@ -6676,15 +6676,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
        @Deprecated
        @Deprecated
        public void legacyDumpProfiles(String packageName, boolean dumpClassesAndMethods)
        public void legacyDumpProfiles(String packageName, boolean dumpClassesAndMethods)
                throws LegacyDexoptDisabledException {
                throws LegacyDexoptDisabledException {
            /* Only the shell, root, or the app user should be able to dump profiles. */
            final int callingUid = Binder.getCallingUid();
            final Computer snapshot = snapshotComputer();
            final Computer snapshot = snapshotComputer();
            final String[] callerPackageNames = snapshot.getPackagesForUid(callingUid);
            if (!PackageManagerServiceUtils.isRootOrShell(callingUid)
                    && !ArrayUtils.contains(callerPackageNames, packageName)) {
                throw new SecurityException("dumpProfiles");
            }

            AndroidPackage pkg = snapshot.getPackage(packageName);
            AndroidPackage pkg = snapshot.getPackage(packageName);
            if (pkg == null) {
            if (pkg == null) {
                throw new IllegalArgumentException("Unknown package: " + packageName);
                throw new IllegalArgumentException("Unknown package: " + packageName);
+5 −0
Original line number Original line Diff line number Diff line
@@ -391,6 +391,11 @@ class PackageManagerShellCommand extends ShellCommand {
    private int runLegacyDexoptCommand(@NonNull String cmd)
    private int runLegacyDexoptCommand(@NonNull String cmd)
            throws RemoteException, LegacyDexoptDisabledException {
            throws RemoteException, LegacyDexoptDisabledException {
        Installer.checkLegacyDexoptDisabled();
        Installer.checkLegacyDexoptDisabled();

        if (!PackageManagerServiceUtils.isRootOrShell(Binder.getCallingUid())) {
            throw new SecurityException("Dexopt shell commands need root or shell access");
        }

        switch (cmd) {
        switch (cmd) {
            case "compile":
            case "compile":
                return runCompile();
                return runCompile();