mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-22 23:01:33 +00:00
Support sepolicy.unlocked
Fix topjohnwu#4914
This commit is contained in:
parent
ff2513e276
commit
b4099fc5f9
@ -65,7 +65,7 @@ protected:
|
|||||||
bool avd_hack = false;
|
bool avd_hack = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void patch_sepolicy(const char *file);
|
void patch_sepolicy(const char *in, const char *out);
|
||||||
bool hijack_sepolicy();
|
bool hijack_sepolicy();
|
||||||
void setup_tmp(const char *path);
|
void setup_tmp(const char *path);
|
||||||
void patch_rw_root();
|
void patch_rw_root();
|
||||||
|
@ -242,8 +242,11 @@ void SARBase::patch_ro_root() {
|
|||||||
// Extract magisk
|
// Extract magisk
|
||||||
extract_files(false);
|
extract_files(false);
|
||||||
|
|
||||||
if ((access(SPLIT_PLAT_CIL, F_OK) != 0 && access("/sepolicy", F_OK) == 0) || !hijack_sepolicy()) {
|
// Oculus Go will use a special sepolicy if unlocked
|
||||||
patch_sepolicy(ROOTOVL "/sepolicy");
|
if (access("/sepolicy.unlocked", F_OK) == 0) {
|
||||||
|
patch_sepolicy("/sepolicy.unlocked", ROOTOVL "/sepolicy.unlocked");
|
||||||
|
} else if ((access(SPLIT_PLAT_CIL, F_OK) != 0 && access("/sepolicy", F_OK) == 0) || !hijack_sepolicy()) {
|
||||||
|
patch_sepolicy("/sepolicy", ROOTOVL "/sepolicy");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mount rootdir
|
// Mount rootdir
|
||||||
@ -297,7 +300,7 @@ void MagiskInit::patch_rw_root() {
|
|||||||
extract_files(true);
|
extract_files(true);
|
||||||
|
|
||||||
if ((!treble && access("/sepolicy", F_OK) == 0) || !hijack_sepolicy()) {
|
if ((!treble && access("/sepolicy", F_OK) == 0) || !hijack_sepolicy()) {
|
||||||
patch_sepolicy("/sepolicy");
|
patch_sepolicy("/sepolicy", "/sepolicy");
|
||||||
}
|
}
|
||||||
|
|
||||||
chdir("/");
|
chdir("/");
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void MagiskInit::patch_sepolicy(const char *file) {
|
void MagiskInit::patch_sepolicy(const char *in, const char *out) {
|
||||||
LOGD("Patching monolithic policy\n");
|
LOGD("Patching monolithic policy\n");
|
||||||
auto sepol = unique_ptr<sepolicy>(sepolicy::from_file("/sepolicy"));
|
auto sepol = unique_ptr<sepolicy>(sepolicy::from_file(in));
|
||||||
|
|
||||||
sepol->magisk_rules();
|
sepol->magisk_rules();
|
||||||
|
|
||||||
@ -27,8 +27,8 @@ void MagiskInit::patch_sepolicy(const char *file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGD("Dumping sepolicy to: [%s]\n", file);
|
LOGD("Dumping sepolicy to: [%s]\n", out);
|
||||||
sepol->to_file(file);
|
sepol->to_file(out);
|
||||||
|
|
||||||
// Remove OnePlus stupid debug sepolicy and use our own
|
// Remove OnePlus stupid debug sepolicy and use our own
|
||||||
if (access("/sepolicy_debug", F_OK) == 0) {
|
if (access("/sepolicy_debug", F_OK) == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user