Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit afff8015 authored by Christopher Tate's avatar Christopher Tate Committed by Android Build Coastguard Worker
Browse files

Fix side effects of trace-ipc and dumpheap commands

These shell commands were implicitly deleting any client-named file for
which the system uid had deletion capability.  They no longer do this,
instead using only the client's own capabilities and file manipulation
modes.

Bug: 185398942
Test: manual "adb shell cmd activity dumpheap system_server /data/system/last-fstrim"
Test: atest CtsPermissionTestCases:ShellCommandPermissionTest
Merged-In: Ie61ab2c3f4bfbd04de09ca99c1116d1129461e8f
Change-Id: Ie61ab2c3f4bfbd04de09ca99c1116d1129461e8f
(cherry picked from commit 6984eaa9)
parent 61130ad2
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@ import com.android.internal.util.HexDump;
import com.android.internal.util.Preconditions;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -660,8 +659,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
            return -1;
        }

        File file = new File(filename);
        file.delete();
        // Writes an error message to stderr on failure
        ParcelFileDescriptor fd = openOutputFileForSystem(filename);
        if (fd == null) {
            return -1;
@@ -812,8 +810,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
        String process = getNextArgRequired();
        String heapFile = getNextArgRequired();

        File file = new File(heapFile);
        file.delete();
        // Writes an error message to stderr on failure
        ParcelFileDescriptor fd = openOutputFileForSystem(heapFile);
        if (fd == null) {
            return -1;