summaryrefslogtreecommitdiffstats
path: root/fixPermissions.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-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;