Skip to content

Commit 9cded09

Browse files
JingMatrixHSSkyBoy
authored andcommitted
Set TMP_PATH env programmatically (JingMatrix#105)
By doing so, we can invoke the binary `bin/zygisk-ptrace64` directly. The wrapper scirpt `zygisk-ctl.sh` is thus removed.
1 parent 05c02ab commit 9cded09

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

loader/build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ plugins {
88
val verCode: Int by rootProject.extra
99
val verName: String by rootProject.extra
1010
val commitHash: String by rootProject.extra
11+
val workDirectory: String by rootProject.extra
1112

1213
fun Project.findInPath(executable: String, property: String): String? {
1314
val pathEnv = System.getenv("PATH")
@@ -29,7 +30,8 @@ val defaultCFlags = arrayOf(
2930
"-Wall", "-Wextra",
3031
"-fno-rtti", "-fno-exceptions",
3132
"-fno-stack-protector", "-fomit-frame-pointer",
32-
"-Wno-builtin-macro-redefined", "-D__FILE__=__FILE_NAME__"
33+
"-Wno-builtin-macro-redefined", "-D__FILE__=__FILE_NAME__",
34+
"-DWORK_DIRECTORY='\"${workDirectory}\"'"
3335
)
3436

3537
val releaseFlags = arrayOf(

loader/src/common/daemon.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
namespace zygiskd {
1111
static std::string TMP_PATH;
1212

13-
void Init(const char *path) { TMP_PATH = path; }
13+
void Init(const char *path) {
14+
TMP_PATH = path;
15+
setenv("TMP_PATH", TMP_PATH.data(), 0);
16+
}
1417

1518
std::string GetTmpPath() { return TMP_PATH; }
1619

loader/src/ptracer/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
// Use string_view literals for efficient, allocation-free string comparisons.
1919
using namespace std::string_view_literals;
2020

21+
const char *const kWorkDirectory = WORK_DIRECTORY;
22+
2123
// The main entry point for the monitoring process.
2224
void init_monitor() {
2325
LOGI("NeoZygisk %s", ZKSU_VERSION);
@@ -72,7 +74,7 @@ static int handle_version();
7274
*/
7375
int main(int argc, char **argv) {
7476
// This initialization is for the daemon's internal logic, not for CLI output.
75-
zygiskd::Init(getenv("TMP_PATH"));
77+
zygiskd::Init(kWorkDirectory);
7678

7779
if (argc < 2) {
7880
print_usage(argv[0]);

module/src/customize.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,11 @@ extract "$ZIPFILE" 'module.prop' "$MODPATH"
110110
extract "$ZIPFILE" 'post-fs-data.sh' "$MODPATH"
111111
extract "$ZIPFILE" 'service.sh' "$MODPATH"
112112
extract "$ZIPFILE" 'uninstall.sh' "$MODPATH"
113-
extract "$ZIPFILE" 'zygisk-ctl.sh' "$MODPATH"
114113
mv "$TMPDIR/sepolicy.rule" "$MODPATH"
115114

116115
mkdir "$MODPATH/bin"
117116
mkdir "$MODPATH/lib"
118117
mkdir "$MODPATH/lib64"
119-
mv "$MODPATH/zygisk-ctl.sh" "$MODPATH/bin/zygisk-ctl"
120118

121119
if [ "$ARCH" = "x86" ]; then
122120
ui_print "- Extracting x86 libraries"
@@ -148,6 +146,7 @@ elif [ "$ARCH" = "arm64" ]; then
148146
mv "$MODPATH/bin/libzygisk_ptrace.so" "$MODPATH/bin/zygisk-ptrace64"
149147
fi
150148

149+
sleep 1
151150
ui_print "- Setting permissions"
152151
set_perm_recursive "$MODPATH/bin" 0 0 0755 0755
153152
set_perm_recursive "$MODPATH/lib" 0 0 0755 0644 u:object_r:system_lib_file:s0

module/src/post-fs-data.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ create_sys_perm() {
2626
chcon u:object_r:system_file:s0 $1
2727
}
2828

29-
export TMP_PATH=@WORK_DIRECTORY@
29+
TMP_PATH=@WORK_DIRECTORY@
3030

3131
if [ -d $TMP_PATH ]; then
3232
rm -rf $TMP_PATH

module/src/zygisk-ctl.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)