summaryrefslogtreecommitdiffstats
path: root/fixPermissions.cpp
diff options
context:
space:
mode:
authorbigbiff bigbiff <bigbiff@teamw.in>2014-01-06 00:13:43 +0100
committerbigbiff bigbiff <bigbiff@teamw.in>2014-02-07 01:56:25 +0100
commit6b600f964471cef977821689185db687f67d2c19 (patch)
tree37f0383b94fa5052b9c060f4078ad539bc3110a0 /fixPermissions.cpp
parentDisable alpha blending for non-transparent bitmaps (diff)
downloadandroid_bootable_recovery-6b600f964471cef977821689185db687f67d2c19.tar
android_bootable_recovery-6b600f964471cef977821689185db687f67d2c19.tar.gz
android_bootable_recovery-6b600f964471cef977821689185db687f67d2c19.tar.bz2
android_bootable_recovery-6b600f964471cef977821689185db687f67d2c19.tar.lz
android_bootable_recovery-6b600f964471cef977821689185db687f67d2c19.tar.xz
android_bootable_recovery-6b600f964471cef977821689185db687f67d2c19.tar.zst
android_bootable_recovery-6b600f964471cef977821689185db687f67d2c19.zip
Diffstat (limited to 'fixPermissions.cpp')
-rw-r--r--fixPermissions.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/fixPermissions.cpp b/fixPermissions.cpp
index 40ac516b0..12ce0b528 100644
--- a/fixPermissions.cpp
+++ b/fixPermissions.cpp
@@ -74,18 +74,48 @@ int fixPermissions::fixDataDataContexts(void) {
struct selinux_opt selinux_options[] = {
{ SELABEL_OPT_PATH, "/file_contexts" }
};
+
selinux_handle = selabel_open(SELABEL_CTX_FILE, selinux_options, 1);
+
if (!selinux_handle)
printf("No file contexts for SELinux\n");
else
printf("SELinux contexts loaded from /file_contexts\n");
+
d = opendir("/data/data");
+
while (( de = readdir(d)) != NULL) {
stat(de->d_name, &sb);
string f = "/data/data/";
f = f + de->d_name;
restorecon(f, &sb);
}
+ closedir(d);
+ return 0;
+}
+
+int fixPermissions::fixDataInternalContexts(void) {
+ DIR *d;
+ struct dirent *de;
+ struct stat sb;
+ string dir;
+
+ if (TWFunc::Path_Exists("/data/media")) {
+ dir = "/data/media";
+ }
+ else {
+ dir = "/data/media/0";
+ }
+ LOGINFO("Fixing %s contexts\n", dir.c_str());
+ d = opendir(dir.c_str());
+
+ while (( de = readdir(d)) != NULL) {
+ stat(de->d_name, &sb);
+ string f;
+ f = dir + de->d_name;
+ restorecon(f, &sb);
+ }
+ closedir(d);
return 0;
}
#endif
@@ -173,8 +203,9 @@ int fixPermissions::fixPerms(bool enable_debug, bool remove_data_for_missing_app
}
}
#ifdef HAVE_SELINUX
- gui_print("Fixing /data/data contexts.\n");
+ gui_print("Fixing /data/data/ contexts.\n");
fixDataDataContexts();
+ fixDataInternalContexts();
#endif
gui_print("Done fixing permissions.\n");
return 0;