Skip to content

Commit 29c6f24

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

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
@@ -106,6 +106,7 @@
106106
import android.os.Process;
107107
import android.os.RemoteCallbackList;
108108
import android.os.RemoteException;
109+
import android.os.SELinux;
109110
import android.os.ServiceManager;
110111
import android.os.StrictMode;
111112
import android.os.SystemClock;
@@ -3032,7 +3033,12 @@ public static File dumpStackTraces(boolean clearTraces, ArrayList<Integer> first
30323033
File tracesFile = new File(tracesPath);
30333034
try {
30343035
File tracesDir = tracesFile.getParentFile();
3035-
if (!tracesDir.exists()) tracesFile.mkdirs();
3036+
if (!tracesDir.exists()) {
3037+
tracesFile.mkdirs();
3038+
if (!SELinux.restorecon(tracesDir)) {
3039+
return null;
3040+
}
3041+
}
30363042
FileUtils.setPermissions(tracesDir.getPath(), 0775, -1, -1); // drwxrwxr-x
30373043

30383044
if (clearTraces && tracesFile.exists()) tracesFile.delete();
@@ -3136,7 +3142,12 @@ final void logAppTooSlow(ProcessRecord app, long startTime, String msg) {
31363142
final File tracesDir = tracesFile.getParentFile();
31373143
final File tracesTmp = new File(tracesDir, "__tmp__");
31383144
try {
3139-
if (!tracesDir.exists()) tracesFile.mkdirs();
3145+
if (!tracesDir.exists()) {
3146+
tracesFile.mkdirs();
3147+
if (!SELinux.restorecon(tracesDir.getPath())) {
3148+
return;
3149+
}
3150+
}
31403151
FileUtils.setPermissions(tracesDir.getPath(), 0775, -1, -1); // drwxrwxr-x
31413152

31423153
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)