aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2016-09-14 15:23:14 -0700
committerClark Scheff <clark@cyngn.com>2016-09-15 10:43:20 -0700
commit06aec1f6f25949db0bd991f54f2ac4e05c891fa2 (patch)
tree13ca7b858c0f6b9c8907a02c0ea84ea89ae2cf93
parentfceb077b6f4e691f031b027e1584e82ce350a5a6 (diff)
downloadvendor_cmsdk-06aec1f6f25949db0bd991f54f2ac4e05c891fa2.zip
vendor_cmsdk-06aec1f6f25949db0bd991f54f2ac4e05c891fa2.tar.gz
vendor_cmsdk-06aec1f6f25949db0bd991f54f2ac4e05c891fa2.tar.bz2
themes: Relabel theme dir after creation
After creating the theme directory it will be labeled as a system_data_file. By calling SELinux.restorecon() the directory will be correctly labeled as a themeservice_app_data_file Change-Id: I73a28da883a467bf8859d879dbe22962424e4a23 TICKET: NIGHTLIES-3349
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/ThemeManagerServiceBroker.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/ThemeManagerServiceBroker.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/ThemeManagerServiceBroker.java
index 771c537..c46608c 100644
--- a/cm/lib/main/java/org/cyanogenmod/platform/internal/ThemeManagerServiceBroker.java
+++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/ThemeManagerServiceBroker.java
@@ -23,6 +23,7 @@ import android.os.FileUtils;
import android.os.IBinder;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
+import android.os.SELinux;
import android.system.ErrnoException;
import android.system.Os;
import android.system.StructStat;
@@ -257,7 +258,10 @@ public class ThemeManagerServiceBroker extends BrokerableCMSystemService<IThemeS
public void onBootPhase(int phase) {
if (phase == PHASE_SYSTEM_SERVICES_READY) {
// create the main theme directory for brokered service
- createDirIfNotExists(ThemeUtils.SYSTEM_THEME_PATH);
+ if (createDirIfNotExists(ThemeUtils.SYSTEM_THEME_PATH)) {
+ // ensure it has the correct selinux label after creation
+ SELinux.restorecon(ThemeUtils.SYSTEM_THEME_PATH);
+ }
if (shouldMigrateFilePermissions()) {
migrateFilePermissions();
@@ -354,13 +358,15 @@ public class ThemeManagerServiceBroker extends BrokerableCMSystemService<IThemeS
return false;
}
- private static void createDirIfNotExists(String dirPath) {
+ private static boolean createDirIfNotExists(String dirPath) {
final File dir = new File(dirPath);
if (!dir.exists()) {
if (dir.mkdir()) {
FileUtils.setPermissions(dir, FileUtils.S_IRWXU |
FileUtils.S_IRWXG| FileUtils.S_IRWXO, -1, -1);
+ return true;
}
}
+ return false;
}
}