summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff Sharkey <jsharkey@android.com> 2016-08-12 12:26:54 -0600
committer Jeff Sharkey <jsharkey@google.com> 2016-08-12 18:34:09 +0000
commit6da39a4406a5768cefb99e5a5426fb22248523bc (patch)
treeb4853d4ec05a6d6308ae625f69eeb9bff1962767
parent41941689b718bada09afa67da116fd426dad0f8c (diff)
Add property to force restorecon to run.
As an optimization, we typically only run restorecon when seapp_contexts changes. This CL checks a property that can be used to always force a restorecon to help investigate boot timing. Bug: 30213213 Change-Id: I4d65c1a4e4a0830ef4a32cd2fae1d3ab188b65cc
-rw-r--r--services/core/java/com/android/server/pm/SELinuxMMAC.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/pm/SELinuxMMAC.java b/services/core/java/com/android/server/pm/SELinuxMMAC.java
index a6350fe8cf35..89705560db7d 100644
--- a/services/core/java/com/android/server/pm/SELinuxMMAC.java
+++ b/services/core/java/com/android/server/pm/SELinuxMMAC.java
@@ -19,6 +19,7 @@ package com.android.server.pm;
import android.content.pm.PackageParser;
import android.content.pm.Signature;
import android.os.Environment;
+import android.os.SystemProperties;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
@@ -64,6 +65,8 @@ public final class SELinuxMMAC {
// to synchronize access during policy load and access attempts.
private static List<Policy> sPolicies = new ArrayList<>();
+ private static final String PROP_FORCE_RESTORECON = "sys.force_restorecon";
+
/** Path to version on rootfs */
private static final File VERSION_FILE = new File("/selinux_version");
@@ -322,6 +325,11 @@ public final class SELinuxMMAC {
* @return Returns true if the restorecon should occur or false otherwise.
*/
public static boolean isRestoreconNeeded(File file) {
+ // To investigate boot timing, allow a property to always force restorecon
+ if (SystemProperties.getBoolean(PROP_FORCE_RESTORECON, false)) {
+ return true;
+ }
+
try {
final byte[] buf = new byte[20];
final int len = Os.getxattr(file.getAbsolutePath(), XATTR_SEAPP_HASH, buf);