You've already forked ReZygisk
mirror of
https://github.com/PerformanC/ReZygisk.git
synced 2025-09-06 06:37:01 +00:00
No hardcode temp dir
This commit is contained in:
@@ -7,19 +7,13 @@
|
||||
#include "socket_utils.h"
|
||||
|
||||
namespace zygiskd {
|
||||
static std::string zygisk_path;
|
||||
void Init(const char *path) {
|
||||
LOGI("zygisk path set to %s", path);
|
||||
zygisk_path = path;
|
||||
}
|
||||
|
||||
int Connect(uint8_t retry) {
|
||||
int fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
||||
struct sockaddr_un addr{
|
||||
.sun_family = AF_UNIX,
|
||||
.sun_path={0},
|
||||
};
|
||||
auto socket_path = zygisk_path + kCPSocketName;
|
||||
auto socket_path = std::string(TMP_PATH) + kCPSocketName;
|
||||
strcpy(addr.sun_path, socket_path.c_str());
|
||||
socklen_t socklen = sizeof(addr);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#endif
|
||||
|
||||
constexpr auto kCPSocketName = "/" LP_SELECT("cp32", "cp64") ".sock";
|
||||
#define TMP_PATH "/debug_ramdisk/zygisksu"
|
||||
inline static const char* TMP_PATH = getenv("TMP_PATH");
|
||||
|
||||
class UniqueFd {
|
||||
using Fd = int;
|
||||
@@ -63,8 +63,6 @@ namespace zygiskd {
|
||||
SystemServerStarted,
|
||||
};
|
||||
|
||||
void Init(const char *path = TMP_PATH);
|
||||
|
||||
bool PingHeartbeat();
|
||||
|
||||
int RequestLogcatFd();
|
||||
|
||||
@@ -12,7 +12,6 @@ void entry(void* handle) {
|
||||
LOGI("Zygisk library injected, version %s", ZKSU_VERSION);
|
||||
self_handle = handle;
|
||||
|
||||
zygiskd::Init();
|
||||
if (!zygiskd::PingHeartbeat()) {
|
||||
LOGE("Zygisk daemon is not running");
|
||||
return;
|
||||
|
||||
@@ -19,7 +19,6 @@ int main(int argc, char **argv) {
|
||||
return 0;
|
||||
} else if (argc >= 3 && argv[1] == "trace"sv) {
|
||||
if (argc >= 4 && argv[3] == "--restart"sv) {
|
||||
zygiskd::Init();
|
||||
zygiskd::ZygoteRestart();
|
||||
}
|
||||
auto pid = strtol(argv[2], 0, 0);
|
||||
|
||||
@@ -37,7 +37,7 @@ enum TracingState {
|
||||
|
||||
std::string monitor_stop_reason;
|
||||
|
||||
constexpr char SOCKET_NAME[] = TMP_PATH "/init_monitor";
|
||||
constexpr char SOCKET_NAME[] = "init_monitor";
|
||||
|
||||
struct EventLoop;
|
||||
|
||||
@@ -136,7 +136,7 @@ struct SocketHandler : public EventHandler {
|
||||
.sun_family = AF_UNIX,
|
||||
.sun_path={0},
|
||||
};
|
||||
strcpy(addr.sun_path, SOCKET_NAME);
|
||||
sprintf(addr.sun_path, "%s/%s", TMP_PATH, SOCKET_NAME);
|
||||
socklen_t socklen = sizeof(sa_family_t) + strlen(addr.sun_path);
|
||||
if (bind(sock_fd_, (struct sockaddr *) &addr, socklen) == -1) {
|
||||
PLOGE("bind socket");
|
||||
@@ -544,7 +544,7 @@ static void updateStatus() {
|
||||
}
|
||||
|
||||
static bool prepare_environment() {
|
||||
prop_path = TMP_PATH "/module.prop";
|
||||
prop_path = std::string(TMP_PATH) + "/module.prop";
|
||||
close(open(prop_path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0644));
|
||||
auto orig_prop = xopen_file("./module.prop", "r");
|
||||
if (orig_prop == nullptr) {
|
||||
@@ -595,7 +595,7 @@ void send_control_command(Command cmd) {
|
||||
.sun_family = AF_UNIX,
|
||||
.sun_path={0},
|
||||
};
|
||||
strcpy(addr.sun_path, SOCKET_NAME);
|
||||
sprintf(addr.sun_path, "%s/%s", TMP_PATH, SOCKET_NAME);
|
||||
socklen_t socklen = sizeof(sa_family_t) + strlen(addr.sun_path);
|
||||
auto nsend = sendto(sockfd, (void *) &cmd, sizeof(cmd), 0, (sockaddr *) &addr, socklen);
|
||||
if (nsend == -1) {
|
||||
|
||||
Reference in New Issue
Block a user