Skip to content

Commit 2bd65b6

Browse files
Jean-Baptiste QueruAndroid Git Automerger
authored andcommitted
am 29c6f24: am 6ffe259: Merge "restorecon /data/anr directory."
* commit '29c6f24b254b4ea1a7d8448980e736355e4badf6': restorecon /data/anr directory.
2 parents 00a8f4f + 29c6f24 commit 2bd65b6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

services/java/com/android/server/am/ActivityManagerService.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
import android.os.Process;
106106
import android.os.RemoteCallbackList;
107107
import android.os.RemoteException;
108+
import android.os.SELinux;
108109
import android.os.ServiceManager;
109110
import android.os.StrictMode;
110111
import android.os.SystemClock;
@@ -3040,7 +3041,12 @@ public static File dumpStackTraces(boolean clearTraces, ArrayList<Integer> first
30403041
File tracesFile = new File(tracesPath);
30413042
try {
30423043
File tracesDir = tracesFile.getParentFile();
3043-
if (!tracesDir.exists()) tracesFile.mkdirs();
3044+
if (!tracesDir.exists()) {
3045+
tracesFile.mkdirs();
3046+
if (!SELinux.restorecon(tracesDir)) {
3047+
return null;
3048+
}
3049+
}
30443050
FileUtils.setPermissions(tracesDir.getPath(), 0775, -1, -1); // drwxrwxr-x
30453051

30463052
if (clearTraces && tracesFile.exists()) tracesFile.delete();
@@ -3144,7 +3150,12 @@ final void logAppTooSlow(ProcessRecord app, long startTime, String msg) {
31443150
final File tracesDir = tracesFile.getParentFile();
31453151
final File tracesTmp = new File(tracesDir, "__tmp__");
31463152
try {
3147-
if (!tracesDir.exists()) tracesFile.mkdirs();
3153+
if (!tracesDir.exists()) {
3154+
tracesFile.mkdirs();
3155+
if (!SELinux.restorecon(tracesDir.getPath())) {
3156+
return;
3157+
}
3158+
}
31483159
FileUtils.setPermissions(tracesDir.getPath(), 0775, -1, -1); // drwxrwxr-x
31493160

31503161
if (tracesFile.exists()) {

services/java/com/android/server/am/DeviceMonitor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.android.server.am;
1818

19+
import android.os.SELinux;
1920
import android.util.Slog;
2021

2122
import java.io.*;
@@ -80,6 +81,9 @@ private void monitor() {
8081
if (!BASE.isDirectory() && !BASE.mkdirs()) {
8182
throw new AssertionError("Couldn't create " + BASE + ".");
8283
}
84+
if (!SELinux.restorecon(BASE)) {
85+
throw new AssertionError("Couldn't restorecon " + BASE + ".");
86+
}
8387
}
8488

8589
private static final File[] PATHS = {

0 commit comments

Comments
 (0)