RESTRICT AUTOMERGE Prevent non-admin users from deleting system apps.
This addresses a security issue where the guest user can remove updates for system apps. With this CL, attempts to uninstall/downgrade system apps will fail if attempted by a non-admin user, unless the DELETE_SYSTEM_APP flag is specified. This is a fixed version of ag/17400663, to address b/236578018. Bug: 170646036 Test: manual, try uninstalling system app update as guest Change-Id: I5eab215cba6528aa4316ed7b20bee544915c1486
This commit is contained in:
@@ -18687,6 +18687,17 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
return PackageManager.DELETE_FAILED_INTERNAL_ERROR;
|
return PackageManager.DELETE_FAILED_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isSystemApp(uninstalledPs)
|
||||||
|
&& (deleteFlags & PackageManager.DELETE_SYSTEM_APP) == 0) {
|
||||||
|
UserInfo userInfo = sUserManager.getUserInfo(userId);
|
||||||
|
if (userInfo == null || !userInfo.isAdmin()) {
|
||||||
|
Slog.w(TAG, "Not removing package " + packageName
|
||||||
|
+ " as only admin user may downgrade system apps");
|
||||||
|
EventLog.writeEvent(0x534e4554, "170646036", -1, packageName);
|
||||||
|
return PackageManager.DELETE_FAILED_USER_RESTRICTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
disabledSystemPs = mSettings.getDisabledSystemPkgLPr(packageName);
|
disabledSystemPs = mSettings.getDisabledSystemPkgLPr(packageName);
|
||||||
// Save the enabled state before we delete the package. When deleting a stub
|
// Save the enabled state before we delete the package. When deleting a stub
|
||||||
// application we always set the enabled state to 'disabled'.
|
// application we always set the enabled state to 'disabled'.
|
||||||
|
|||||||
Reference in New Issue
Block a user