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 Change-Id: Ie61ab2c3f4bfbd04de09ca99c1116d1129461e8f
This commit is contained in:
committed by
Chris Tate
parent
dd894ae859
commit
76e8e04703
@@ -94,7 +94,6 @@ import com.android.internal.util.MemInfoReader;
|
|||||||
import com.android.server.compat.PlatformCompat;
|
import com.android.server.compat.PlatformCompat;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
@@ -787,8 +786,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(filename);
|
// Writes an error message to stderr on failure
|
||||||
file.delete();
|
|
||||||
ParcelFileDescriptor fd = openFileForSystem(filename, "w");
|
ParcelFileDescriptor fd = openFileForSystem(filename, "w");
|
||||||
if (fd == null) {
|
if (fd == null) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -942,16 +940,16 @@ final class ActivityManagerShellCommand extends ShellCommand {
|
|||||||
String logNameTimeString = LOG_NAME_TIME_FORMATTER.format(localDateTime);
|
String logNameTimeString = LOG_NAME_TIME_FORMATTER.format(localDateTime);
|
||||||
heapFile = "/data/local/tmp/heapdump-" + logNameTimeString + ".prof";
|
heapFile = "/data/local/tmp/heapdump-" + logNameTimeString + ".prof";
|
||||||
}
|
}
|
||||||
pw.println("File: " + heapFile);
|
|
||||||
pw.flush();
|
|
||||||
|
|
||||||
File file = new File(heapFile);
|
// Writes an error message to stderr on failure
|
||||||
file.delete();
|
|
||||||
ParcelFileDescriptor fd = openFileForSystem(heapFile, "w");
|
ParcelFileDescriptor fd = openFileForSystem(heapFile, "w");
|
||||||
if (fd == null) {
|
if (fd == null) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pw.println("File: " + heapFile);
|
||||||
|
pw.flush();
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
|
||||||
final RemoteCallback finishCallback = new RemoteCallback(new OnResultListener() {
|
final RemoteCallback finishCallback = new RemoteCallback(new OnResultListener() {
|
||||||
|
|||||||
Reference in New Issue
Block a user