mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 02:25:28 +00:00
Limit sepolicy load to Android Q only
It seems both Android cancers, Samsung and Huawei devices, don't like preloading sepolicy. For a temporary solution now is to limit the sepolicy loading to Android Q only.
This commit is contained in:
parent
c0447009db
commit
957feca626
@ -146,12 +146,12 @@ private:
|
|||||||
raw_data init{};
|
raw_data init{};
|
||||||
raw_data config{};
|
raw_data config{};
|
||||||
int root = -1;
|
int root = -1;
|
||||||
|
char **argv;
|
||||||
|
bool load_sepol = false;
|
||||||
bool mnt_system = false;
|
bool mnt_system = false;
|
||||||
bool mnt_vendor = false;
|
bool mnt_vendor = false;
|
||||||
bool mnt_product = false;
|
bool mnt_product = false;
|
||||||
bool mnt_odm = false;
|
bool mnt_odm = false;
|
||||||
bool kirin = false;
|
|
||||||
char **argv;
|
|
||||||
|
|
||||||
void load_kernel_info();
|
void load_kernel_info();
|
||||||
void preset();
|
void preset();
|
||||||
@ -209,7 +209,9 @@ void MagiskInit::load_kernel_info() {
|
|||||||
cmdline[read(fd, cmdline, sizeof(cmdline))] = '\0';
|
cmdline[read(fd, cmdline, sizeof(cmdline))] = '\0';
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
bool skip_initramfs = false, enter_recovery = false;
|
bool skip_initramfs = false;
|
||||||
|
bool enter_recovery = false;
|
||||||
|
bool kirin = false;
|
||||||
|
|
||||||
parse_cmdline([&](auto key, auto value) -> void {
|
parse_cmdline([&](auto key, auto value) -> void {
|
||||||
LOGD("cmdline: [%s]=[%s]\n", key.data(), value);
|
LOGD("cmdline: [%s]=[%s]\n", key.data(), value);
|
||||||
@ -348,6 +350,10 @@ void MagiskInit::early_mount() {
|
|||||||
xmkdir("/system", 0755);
|
xmkdir("/system", 0755);
|
||||||
xmount("/system_root/system", "/system", nullptr, MS_BIND, nullptr);
|
xmount("/system_root/system", "/system", nullptr, MS_BIND, nullptr);
|
||||||
|
|
||||||
|
// Android Q
|
||||||
|
if (is_lnk("/system_root/init"))
|
||||||
|
load_sepol = true;
|
||||||
|
|
||||||
// Copy if these partitions are symlinks
|
// Copy if these partitions are symlinks
|
||||||
link_root("/vendor");
|
link_root("/vendor");
|
||||||
link_root("/product");
|
link_root("/product");
|
||||||
@ -449,7 +455,7 @@ bool MagiskInit::patch_sepolicy() {
|
|||||||
dump_policydb("/sepolicy");
|
dump_policydb("/sepolicy");
|
||||||
|
|
||||||
// Load policy to kernel so we can label rootfs
|
// Load policy to kernel so we can label rootfs
|
||||||
if (!kirin)
|
if (load_sepol)
|
||||||
dump_policydb(SELINUX_LOAD);
|
dump_policydb(SELINUX_LOAD);
|
||||||
|
|
||||||
// Remove OnePlus stupid debug sepolicy and use our own
|
// Remove OnePlus stupid debug sepolicy and use our own
|
||||||
@ -483,7 +489,7 @@ bool MagiskInit::read_dt_fstab(const char *mnt_point, char *partname, char *part
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define umount_part(part) \
|
#define umount_root(part) \
|
||||||
if (mnt_##part) \
|
if (mnt_##part) \
|
||||||
umount("/" #part);
|
umount("/" #part);
|
||||||
|
|
||||||
@ -491,10 +497,10 @@ void MagiskInit::cleanup() {
|
|||||||
umount(SELINUX_MNT);
|
umount(SELINUX_MNT);
|
||||||
umount("/sys");
|
umount("/sys");
|
||||||
umount("/proc");
|
umount("/proc");
|
||||||
umount_part(system);
|
umount_root(system);
|
||||||
umount_part(vendor);
|
umount_root(vendor);
|
||||||
umount_part(product);
|
umount_root(product);
|
||||||
umount_part(odm);
|
umount_root(odm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void patch_socket_name(const char *path) {
|
static inline void patch_socket_name(const char *path) {
|
||||||
|
Loading…
Reference in New Issue
Block a user