From 3dc7d77ea9045be77b05cc3cf3d91869bf18ca28 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 19 Mar 2022 17:07:46 -0700 Subject: [PATCH] Patch monolithic sepolicy only if not treble --- native/jni/init/rootdir.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/native/jni/init/rootdir.cpp b/native/jni/init/rootdir.cpp index c5ad0279e..87ca33981 100644 --- a/native/jni/init/rootdir.cpp +++ b/native/jni/init/rootdir.cpp @@ -278,6 +278,12 @@ void MagiskInit::patch_rw_root() { patch_init_rc("/init.rc", "/init.p.rc", "/sbin"); rename("/init.p.rc", "/init.rc"); + bool treble; + { + auto init = mmap_data("/init"); + treble = init.contains(SPLIT_PLAT_CIL); + } + xmkdir(PRE_TMPDIR, 0); setup_tmp(PRE_TMPDIR); chdir(PRE_TMPDIR); @@ -303,7 +309,7 @@ void MagiskInit::patch_rw_root() { } } - if (access("/sepolicy", F_OK) == 0) { + if (!treble && access("/sepolicy", F_OK) == 0) { patch_sepolicy("/sepolicy"); } else { hijack_sepolicy();