From 8a2b96bb0a1d901beb9cc9635c1fe9a265799b36 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Fri, 28 Dec 2018 17:23:29 -0800 Subject: [PATCH] Clarify shell/root users also have DUMP permission This is a follow up CL to my previous CL [1], which aimed to streamline and centralize when and how caller verifications are performed inside InputMethodManagerService#onShellCommand(). The goal of this change is just to make it clear that shell/root users also have DUMP permission. There should be no behavior change as long as those users have DUMP permission because IMMS#onShellCommand() is already locked down to accept IPCs only from these two UIDs [2]. The point is that ShellCommand#handleDefaultCommands() by default dispatches 'dump' command to Binder#doDump() method. Thus it would make sense to clarify that DUMP permission is also granted to shell/root users for completeness. [1]: I6fd47b5cc1e7da7222774df20247a2c69a70f45b db25df71be4c1bcc654f69ce9a8bff7e3ef46360 [2]: If87189563ccaacd4f9c666bab4f9ad08a9343084 b8d240fa3f96b7b4ea35dd271beda789044d63ab Bug: 34886274 Test: 'adb shell cmd input_method dump' still work Change-Id: If91137e0c144d90ac3046f30607e36bb957a7e0e --- .../inputmethod/InputMethodManagerService.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 99979c18b5201..3364e2818608d 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -4624,17 +4624,20 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } @RequiresPermission(allOf = { + Manifest.permission.DUMP, + Manifest.permission.INTERACT_ACROSS_USERS_FULL, Manifest.permission.WRITE_SECURE_SETTINGS, - Manifest.permission.INTERACT_ACROSS_USERS_FULL}) + }) @BinderThread @ShellCommandResult @Override public int onCommand(@Nullable String cmd) { // For shell command, require all the permissions here in favor of code simplicity. - mService.mContext.enforceCallingPermission( - Manifest.permission.INTERACT_ACROSS_USERS_FULL, null); - mService.mContext.enforceCallingPermission( - Manifest.permission.WRITE_SECURE_SETTINGS, null); + Arrays.asList( + Manifest.permission.DUMP, + Manifest.permission.INTERACT_ACROSS_USERS_FULL, + Manifest.permission.WRITE_SECURE_SETTINGS + ).forEach(permission -> mService.mContext.enforceCallingPermission(permission, null)); final long identity = Binder.clearCallingIdentity(); try {