From c0a2e3674c2767e5c0f9d13c94b56822d47a7b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=8B=E9=A1=B5?= <31466456+canyie@users.noreply.github.com> Date: Thu, 2 Sep 2021 22:54:53 +0800 Subject: [PATCH] Reset file context from adb_data_file In some cases (like weird ROMs that allow init to relabel context from system_file), module files will have an incorrent context, which will causes module not working properly. See https://github.com/RikkaApps/Riru/wiki/Explanation-about-incorrect-SELinux-rules-from-third-party-ROMs-cause-Riru-not-working --- native/jni/core/restorecon.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/native/jni/core/restorecon.cpp b/native/jni/core/restorecon.cpp index f4454dfd1..b97de1d0d 100644 --- a/native/jni/core/restorecon.cpp +++ b/native/jni/core/restorecon.cpp @@ -19,7 +19,7 @@ static void restore_syscon(int dirfd) { char *con; if (fgetfilecon(dirfd, &con) >= 0) { - if (strlen(con) == 0 || strcmp(con, UNLABEL_CON) == 0) + if (strlen(con) == 0 || strcmp(con, UNLABEL_CON) == 0 || strcmp(con, ADB_CON) == 0) fsetfilecon(dirfd, SYSTEM_CON); freecon(con); } @@ -31,13 +31,13 @@ static void restore_syscon(int dirfd) { restore_syscon(fd); } else if (entry->d_type == DT_REG) { if (fgetfilecon(fd, &con) >= 0) { - if (con[0] == '\0' || strcmp(con, UNLABEL_CON) == 0) + if (con[0] == '\0' || strcmp(con, UNLABEL_CON) == 0 || strcmp(con, ADB_CON) == 0) fsetfilecon(fd, SYSTEM_CON); freecon(con); } } else if (entry->d_type == DT_LNK) { getfilecon_at(dirfd, entry->d_name, &con); - if (con[0] == '\0' || strcmp(con, UNLABEL_CON) == 0) + if (con[0] == '\0' || strcmp(con, UNLABEL_CON) == 0 || strcmp(con, ADB_CON) == 0) setfilecon_at(dirfd, entry->d_name, con); freecon(con); }