Merge "Only allow access to the dexopt commands from root or shell." into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
71498b565e
@@ -6675,15 +6675,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);
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user