summaryrefslogtreecommitdiffstats
path: root/fixPermissions.cpp
diff options
context:
space:
mode:
authorDees Troy <dees_troy@teamw.in>2014-02-07 19:44:16 +0100
committerGerrit Code Review <gerrit2@gerrit>2014-02-07 19:44:16 +0100
commita8aac9038f5399ec28ec739966330c379bbac4db (patch)
tree6325f248a289c19e0d217319996f9af3c1f60a6d /fixPermissions.cpp
parentMerge "Implement mouse cursor" into android-4.4 (diff)
parentRestore contexts when doing mkdierhier in libtar (diff)
downloadandroid_bootable_recovery-a8aac9038f5399ec28ec739966330c379bbac4db.tar
android_bootable_recovery-a8aac9038f5399ec28ec739966330c379bbac4db.tar.gz
android_bootable_recovery-a8aac9038f5399ec28ec739966330c379bbac4db.tar.bz2
android_bootable_recovery-a8aac9038f5399ec28ec739966330c379bbac4db.tar.lz
android_bootable_recovery-a8aac9038f5399ec28ec739966330c379bbac4db.tar.xz
android_bootable_recovery-a8aac9038f5399ec28ec739966330c379bbac4db.tar.zst
android_bootable_recovery-a8aac9038f5399ec28ec739966330c379bbac4db.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;