-
Notifications
You must be signed in to change notification settings - Fork 1
/
zygote64_32.patch
85 lines (77 loc) · 2.89 KB
/
zygote64_32.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
From 8b05a547249114663e6b2b45a59fed4e731d674e Mon Sep 17 00:00:00 2001
From: GitHub Actions <actions@github.com>
Date: Mon, 26 Aug 2024 12:40:47 +0800
Subject: [PATCH] zygote64_32
---
native/src/init/rootdir.cpp | 48 +++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/native/src/init/rootdir.cpp b/native/src/init/rootdir.cpp
index 2f7ff0b30..2c745d7f4 100644
--- a/native/src/init/rootdir.cpp
+++ b/native/src/init/rootdir.cpp
@@ -16,6 +16,8 @@ static string magic_mount_list;
#define NEW_INITRC_DIR "/system/etc/init/hw"
#define INIT_RC "init.rc"
+#define VENDOR_DIR "/vendor"
+#define BUILD_PROP "build.prop"
static void magic_mount(const string &sdir, const string &ddir = "") {
auto dir = xopen_dir(sdir.data());
@@ -165,6 +167,47 @@ static void patch_rc_scripts(const char *src_path, const char *tmp_path, bool wr
}
}
+static void patch_build_prop(const char *src_path) {
+ auto src_dir = xopen_dir(src_path);
+ if (!src_dir) return;
+ int src_fd = dirfd(src_dir.get());
+
+ auto dest_dir = [&] {
+ char buf[PATH_MAX] = {};
+ ssprintf(buf, sizeof(buf), ROOTOVL "%s", src_path);
+ xmkdirs(buf, 0755);
+ return xopen_dir(buf);
+ }();
+ if (!dest_dir) return;
+ int dest_fd = dirfd(dest_dir.get());
+
+ {
+ auto src = xopen_file(xopenat(src_fd, BUILD_PROP, O_RDONLY | O_CLOEXEC, 0), "re");
+ if (!src) return;
+ auto dest = xopen_file(
+ xopenat(dest_fd, BUILD_PROP, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0), "we");
+ if (!dest) return;
+ LOGD("Patching " BUILD_PROP " in %s\n", src_path);
+ file_readline(false, src.get(), [&dest](string_view line) -> bool {
+ if (line.starts_with("ro.zygote=zygote64")) {
+ fprintf(dest.get(), "ro.zygote=zygote64_32\n");
+ return true;
+ }
+ if (line.starts_with("ro.vendor.product.cpu.abilist=arm64-v8a")) {
+ fprintf(dest.get(), "ro.vendor.product.cpu.abilist=arm64-v8a,armeabi-v7a,armeabi\n");
+ return true;
+ }
+ if (line.starts_with("ro.vendor.product.cpu.abilist32=")) {
+ fprintf(dest.get(), "ro.vendor.product.cpu.abilist32=armeabi-v7a,armeabi\n");
+ return true;
+ }
+ fprintf(dest.get(), "%s", line.data());
+ return true;
+ });
+ fclone_attr(fileno(src.get()), fileno(dest.get()));
+ }
+}
+
static void load_overlay_rc(const char *overlay) {
auto dir = open_dir(overlay);
if (!dir) return;
@@ -324,6 +367,11 @@ void MagiskInit::patch_ro_root() {
patch_rc_scripts("/", tmp_dir.data(), false);
}
+ // Patch build.prop
+ if (access(VENDOR_DIR "/" BUILD_PROP, F_OK) == 0) {
+ patch_build_prop(VENDOR_DIR);
+ }
+
// Extract overlay archives
extract_files(false);
--
2.43.0