You've already forked ReZygisk
mirror of
https://github.com/PerformanC/ReZygisk.git
synced 2025-09-06 06:37:01 +00:00
Use relative path
This commit is contained in:
2
loader/src/external/liblsplt
vendored
2
loader/src/external/liblsplt
vendored
Submodule loader/src/external/liblsplt updated: 204a163688...b254b5b9a5
@@ -18,7 +18,9 @@ static void zygisk_cleanup_wait() {
|
|||||||
|
|
||||||
extern "C" [[gnu::visibility("default")]]
|
extern "C" [[gnu::visibility("default")]]
|
||||||
void entry(void *handle) {
|
void entry(void *handle) {
|
||||||
|
#ifdef NDEBUG
|
||||||
logging::setfd(zygiskd::RequestLogcatFd());
|
logging::setfd(zygiskd::RequestLogcatFd());
|
||||||
|
#endif
|
||||||
self_handle = handle;
|
self_handle = handle;
|
||||||
|
|
||||||
LOGD("Load injector successfully");
|
LOGD("Load injector successfully");
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ void Constructor() {
|
|||||||
std::string native_bridge;
|
std::string native_bridge;
|
||||||
do {
|
do {
|
||||||
if (!zygiskd::PingHeartbeat()) break;
|
if (!zygiskd::PingHeartbeat()) break;
|
||||||
|
#ifdef NDEBUG
|
||||||
logging::setfd(zygiskd::RequestLogcatFd());
|
logging::setfd(zygiskd::RequestLogcatFd());
|
||||||
|
#endif
|
||||||
LOGI("Read native bridge");
|
LOGI("Read native bridge");
|
||||||
native_bridge = zygiskd::ReadNativeBridge();
|
native_bridge = zygiskd::ReadNativeBridge();
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ extract "$ZIPFILE" 'daemon.sh' "$MODPATH"
|
|||||||
extract "$ZIPFILE" 'module.prop' "$MODPATH"
|
extract "$ZIPFILE" 'module.prop' "$MODPATH"
|
||||||
extract "$ZIPFILE" 'post-fs-data.sh' "$MODPATH"
|
extract "$ZIPFILE" 'post-fs-data.sh' "$MODPATH"
|
||||||
extract "$ZIPFILE" 'sepolicy.rule' "$MODPATH"
|
extract "$ZIPFILE" 'sepolicy.rule' "$MODPATH"
|
||||||
extract "$ZIPFILE" 'service.sh' "$MODPATH"
|
|
||||||
|
|
||||||
HAS32BIT=false && [ -d "/system/lib" ] && HAS32BIT=true
|
HAS32BIT=false && [ -d "/system/lib" ] && HAS32BIT=true
|
||||||
HAS64BIT=false && [ -d "/system/lib64" ] && HAS64BIT=true
|
HAS64BIT=false && [ -d "/system/lib64" ] && HAS64BIT=true
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#!/system/bin/sh
|
#!/system/bin/sh
|
||||||
|
|
||||||
DEBUG=@DEBUG@
|
DEBUG=@DEBUG@
|
||||||
MODDIR=${0%/*}
|
|
||||||
|
|
||||||
# shellcheck disable=SC2155
|
# shellcheck disable=SC2155
|
||||||
export NATIVE_BRIDGE=$(getprop ro.dalvik.vm.native.bridge)
|
export NATIVE_BRIDGE=$(getprop ro.dalvik.vm.native.bridge)
|
||||||
@@ -9,4 +8,4 @@ export NATIVE_BRIDGE=$(getprop ro.dalvik.vm.native.bridge)
|
|||||||
|
|
||||||
log -p i -t "zygisksu" "Start watchdog"
|
log -p i -t "zygisksu" "Start watchdog"
|
||||||
resetprop ro.dalvik.vm.native.bridge libzygiskloader.so
|
resetprop ro.dalvik.vm.native.bridge libzygiskloader.so
|
||||||
exec "$MODDIR/bin/zygiskwd" "watchdog" >/dev/null 2>&1
|
exec "bin/zygiskwd" "watchdog" >/dev/null 2>&1
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
#!/system/bin/sh
|
#!/system/bin/sh
|
||||||
|
|
||||||
MODDIR=${0%/*}
|
MODDIR=${0%/*}
|
||||||
|
|
||||||
|
cd $MODDIR
|
||||||
export NATIVE_BRIDGE=$(getprop ro.dalvik.vm.native.bridge)
|
export NATIVE_BRIDGE=$(getprop ro.dalvik.vm.native.bridge)
|
||||||
unshare -m sh -c "$MODDIR/daemon.sh $@&"
|
|
||||||
|
unshare -m sh -c "./daemon.sh $@&"
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
#!/system/bin/sh
|
|
||||||
@@ -26,11 +26,9 @@ pub const PROP_NATIVE_BRIDGE: &str = "ro.dalvik.vm.native.bridge";
|
|||||||
|
|
||||||
pub const SOCKET_PLACEHOLDER: &str = "socket_placeholder";
|
pub const SOCKET_PLACEHOLDER: &str = "socket_placeholder";
|
||||||
|
|
||||||
pub const PATH_KSU_MODULE_DIR: &str = "/data/adb/ksu/modules";
|
pub const PATH_MODULE_DIR: &str = "..";
|
||||||
pub const PATH_ZYGISKSU_DIR: &str = concatcp!(PATH_KSU_MODULE_DIR, "/zygisksu");
|
pub const PATH_ZYGISKD32: &str = "bin/zygiskd32";
|
||||||
pub const PATH_ZYGISKD32: &str = concatcp!(PATH_ZYGISKSU_DIR, "/bin/zygiskd32");
|
pub const PATH_ZYGISKD64: &str = "bin/zygiskd64";
|
||||||
pub const PATH_ZYGISKD64: &str = concatcp!(PATH_ZYGISKSU_DIR, "/bin/zygiskd64");
|
|
||||||
pub const PATH_DAEMON_LOCK: &str = concatcp!(PATH_ZYGISKSU_DIR, "/zygiskd.lock");
|
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, TryFromPrimitive)]
|
#[derive(Debug, Eq, PartialEq, TryFromPrimitive)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
use crate::{constants, utils};
|
use crate::{constants, utils};
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use nix::fcntl::{flock, FlockArg};
|
|
||||||
use nix::unistd::{getgid, getuid};
|
use nix::unistd::{getgid, getuid};
|
||||||
use std::os::unix::prelude::AsRawFd;
|
|
||||||
use std::process::{Child, Command};
|
use std::process::{Child, Command};
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use std::{fs, thread};
|
use std::{fs, thread};
|
||||||
|
use std::os::unix::net::UnixListener;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
static mut LOCK_FILE: Option<fs::File> = None;
|
static mut LOCK: Option<UnixListener> = None;
|
||||||
|
|
||||||
pub fn entry() -> Result<()> {
|
pub fn entry() -> Result<()> {
|
||||||
log::info!("Start zygisksu watchdog");
|
log::info!("Start zygisksu watchdog");
|
||||||
@@ -32,7 +31,6 @@ fn check_permission() -> Result<()> {
|
|||||||
|
|
||||||
let context = fs::read_to_string("/proc/self/attr/current")?;
|
let context = fs::read_to_string("/proc/self/attr/current")?;
|
||||||
let context = context.trim_end_matches('\0');
|
let context = context.trim_end_matches('\0');
|
||||||
//TODO: remove magisk context after debug finished
|
|
||||||
if context != "u:r:su:s0" && context != "u:r:magisk:s0" {
|
if context != "u:r:su:s0" && context != "u:r:magisk:s0" {
|
||||||
bail!("SELinux context incorrect: {context}");
|
bail!("SELinux context incorrect: {context}");
|
||||||
}
|
}
|
||||||
@@ -42,19 +40,10 @@ fn check_permission() -> Result<()> {
|
|||||||
|
|
||||||
fn ensure_single_instance() -> Result<()> {
|
fn ensure_single_instance() -> Result<()> {
|
||||||
log::info!("Ensure single instance");
|
log::info!("Ensure single instance");
|
||||||
let metadata = fs::metadata(constants::PATH_ZYGISKSU_DIR);
|
let name = String::from("zygiskwd") + constants::SOCKET_PLACEHOLDER;
|
||||||
if metadata.is_err() || !metadata.unwrap().is_dir() {
|
match utils::abstract_namespace_socket(&name) {
|
||||||
bail!("Zygisksu is not installed");
|
Ok(socket) => unsafe { LOCK = Some(socket) },
|
||||||
}
|
Err(e) => bail!("Failed to acquire lock: {e}. Maybe another instance is running?")
|
||||||
unsafe {
|
|
||||||
match fs::File::create(constants::PATH_DAEMON_LOCK) {
|
|
||||||
Ok(file) => LOCK_FILE = Some(file),
|
|
||||||
Err(e) => bail!("Failed to open lock file: {e}"),
|
|
||||||
};
|
|
||||||
let fd = LOCK_FILE.as_ref().unwrap().as_raw_fd();
|
|
||||||
if let Err(e) = flock(fd, FlockArg::LockExclusiveNonblock) {
|
|
||||||
bail!("Failed to acquire lock: {e}. Maybe another instance is running?");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ fn get_arch() -> Result<&'static str> {
|
|||||||
|
|
||||||
fn load_modules(arch: &str) -> Result<Vec<Module>> {
|
fn load_modules(arch: &str) -> Result<Vec<Module>> {
|
||||||
let mut modules = Vec::new();
|
let mut modules = Vec::new();
|
||||||
let dir = match fs::read_dir(constants::PATH_KSU_MODULE_DIR) {
|
let dir = match fs::read_dir(constants::PATH_MODULE_DIR) {
|
||||||
Ok(dir) => dir,
|
Ok(dir) => dir,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::warn!("Failed reading modules directory: {}", e);
|
log::warn!("Failed reading modules directory: {}", e);
|
||||||
@@ -137,8 +137,8 @@ fn create_memfd(name: &str, so_path: &PathBuf) -> Result<Memfd> {
|
|||||||
|
|
||||||
fn create_daemon_socket() -> Result<UnixListener> {
|
fn create_daemon_socket() -> Result<UnixListener> {
|
||||||
utils::set_socket_create_context("u:r:zygote:s0")?;
|
utils::set_socket_create_context("u:r:zygote:s0")?;
|
||||||
let suffix = lp_select!("zygiskd32", "zygiskd64");
|
let prefix = lp_select!("zygiskd32", "zygiskd64");
|
||||||
let name = String::from(suffix) + constants::SOCKET_PLACEHOLDER;
|
let name = String::from(prefix) + constants::SOCKET_PLACEHOLDER;
|
||||||
let listener = utils::abstract_namespace_socket(&name)?;
|
let listener = utils::abstract_namespace_socket(&name)?;
|
||||||
log::debug!("Daemon socket: {name}");
|
log::debug!("Daemon socket: {name}");
|
||||||
Ok(listener)
|
Ok(listener)
|
||||||
@@ -221,7 +221,7 @@ fn handle_daemon_action(mut stream: UnixStream, context: &Context) -> Result<()>
|
|||||||
DaemonSocketAction::GetModuleDir => {
|
DaemonSocketAction::GetModuleDir => {
|
||||||
let index = stream.read_usize()?;
|
let index = stream.read_usize()?;
|
||||||
let module = &context.modules[index];
|
let module = &context.modules[index];
|
||||||
let dir = format!("{}/{}", constants::PATH_KSU_MODULE_DIR, module.name);
|
let dir = format!("{}/{}", constants::PATH_MODULE_DIR, module.name);
|
||||||
let dir = fs::File::open(dir)?;
|
let dir = fs::File::open(dir)?;
|
||||||
stream.send_fd(dir.as_raw_fd())?;
|
stream.send_fd(dir.as_raw_fd())?;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user