Refactor sepolicy.rules resolve native

Co-authored-by: LoveSy <shana@zju.edu.cn>
This commit is contained in:
vvb2060
2023-03-08 14:42:54 +08:00
committed by John Wu
parent 4de93cfd4b
commit 362eea741f
12 changed files with 163 additions and 122 deletions

View File

@@ -505,3 +505,15 @@ string find_apk_path(const char *pkg) {
string path(buf);
return path.append("/base.apk");
}
string find_rules_dir(const char *base_dir) {
string rules_dir = base_dir;
if (access((rules_dir + "/unencrypted").data(), F_OK) == 0) {
rules_dir += "/unencrypted/magisk";
} else if (access((rules_dir + "/adb").data(), F_OK) == 0) {
rules_dir += "/adb/modules";
} else {
rules_dir += "/magisk";
}
return rules_dir;
}

View File

@@ -107,6 +107,7 @@ void frm_rf(int dirfd);
void clone_dir(int src, int dest);
std::vector<mount_info> parse_mount_info(const char *pid);
std::string find_apk_path(const char *pkg);
std::string find_rules_dir(const char *base_dir);
using sFILE = std::unique_ptr<FILE, decltype(&fclose)>;
using sDIR = std::unique_ptr<DIR, decltype(&closedir)>;