summaryrefslogtreecommitdiffstats
path: root/services/devicepolicy
diff options
context:
space:
mode:
authorJulia Reynolds <juliacr@google.com>2015-03-05 10:06:41 -0500
committerJulia Reynolds <juliacr@google.com>2015-03-05 11:47:14 -0500
commit1c3754a35c434e4102c7ac3dceb887fa137b153b (patch)
treedd71ae5dbf0bd6181abb4ed6cf688be0a39b6b97 /services/devicepolicy
parentaf3435481214b839fc462fcfe5e5ff378a31fb91 (diff)
downloadframeworks_base-1c3754a35c434e4102c7ac3dceb887fa137b153b.zip
frameworks_base-1c3754a35c434e4102c7ac3dceb887fa137b153b.tar.gz
frameworks_base-1c3754a35c434e4102c7ac3dceb887fa137b153b.tar.bz2
Add security check for clearDeviceInitializer in the service.
Bug: 19230954 Change-Id: I5c648492bef0d2b579b6f59b91afc890e3092d36
Diffstat (limited to 'services/devicepolicy')
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index aa9d8dd..fc9ff76 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -3940,15 +3940,21 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
@Override
- public void clearDeviceInitializer(String packageName) {
+ public void clearDeviceInitializer(ComponentName who) {
if (!mHasFeature) {
return;
}
- if (packageName == null) {
- throw new NullPointerException("packageName is null");
+ Preconditions.checkNotNull(who, "ComponentName is null");
+
+ ActiveAdmin admin = getActiveAdminUncheckedLocked(who, UserHandle.getCallingUserId());
+
+ if (admin.getUid() != Binder.getCallingUid()) {
+ throw new SecurityException("Admin " + who + " is not owned by uid "
+ + Binder.getCallingUid());
}
- if (!isDeviceInitializer(packageName) && !isDeviceOwner(packageName)) {
+ if (!isDeviceInitializer(admin.info.getPackageName())
+ && !isDeviceOwner(admin.info.getPackageName())) {
throw new SecurityException(
"clearDeviceInitializer can only be called by the device initializer/owner");
}