Consistent dump() permission checking.
This change introduces new methods on DumpUtils that can check if the caller has DUMP and/or PACKAGE_USAGE_STATS access. It then moves all existing dump() methods to use these checks so that we emit consistent error messages. Test: cts-tradefed run commandAndExit cts-dev -m CtsSecurityTestCases -t android.security.cts.ServicePermissionsTest Bug: 32806790 Change-Id: Iaff6b9506818ee082b1e169c89ebe1001b3bfeca
This commit is contained in:
@@ -125,6 +125,7 @@ import com.android.internal.net.VpnConfig;
|
||||
import com.android.internal.net.VpnInfo;
|
||||
import com.android.internal.net.VpnProfile;
|
||||
import com.android.internal.util.AsyncChannel;
|
||||
import com.android.internal.util.DumpUtils;
|
||||
import com.android.internal.util.IndentingPrintWriter;
|
||||
import com.android.internal.util.MessageUtils;
|
||||
import com.android.internal.util.WakeupMessage;
|
||||
@@ -1927,14 +1928,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
@Override
|
||||
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
|
||||
final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ");
|
||||
if (mContext.checkCallingOrSelfPermission(
|
||||
android.Manifest.permission.DUMP)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
pw.println("Permission Denial: can't dump ConnectivityService " +
|
||||
"from from pid=" + Binder.getCallingPid() + ", uid=" +
|
||||
Binder.getCallingUid());
|
||||
return;
|
||||
}
|
||||
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
|
||||
|
||||
if (argsContain(args, "--diag")) {
|
||||
dumpNetworkDiagnostics(pw);
|
||||
|
||||
Reference in New Issue
Block a user