mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-05-03 07:54:26 +02:00
Fix zygisk module load
This commit is contained in:
parent
bb02ea3a20
commit
7f6c9e8411
@ -4,10 +4,10 @@ use crate::ffi::{
|
|||||||
get_magisk_tmp, restore_zygisk_prop, update_deny_flags, ZygiskRequest, ZygiskStateFlags,
|
get_magisk_tmp, restore_zygisk_prop, update_deny_flags, ZygiskRequest, ZygiskStateFlags,
|
||||||
};
|
};
|
||||||
use crate::socket::{IpcRead, UnixSocketExt};
|
use crate::socket::{IpcRead, UnixSocketExt};
|
||||||
use base::libc::{O_CLOEXEC, O_CREAT, O_RDONLY};
|
use base::libc::{O_CLOEXEC, O_CREAT, O_RDONLY, STDOUT_FILENO};
|
||||||
use base::{
|
use base::{
|
||||||
cstr, error, fork_dont_care, libc, open_fd, raw_cstr, warn, Directory, FsPathBuf, LoggedError,
|
cstr, error, fork_dont_care, libc, open_fd, raw_cstr, warn, Directory, FsPathBuf, LoggedError,
|
||||||
LoggedResult, Utf8CStrBufArr, WriteExt,
|
LoggedResult, ResultExt, Utf8CStrBufArr, WriteExt,
|
||||||
};
|
};
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::os::fd::{AsRawFd, FromRawFd, RawFd};
|
use std::os::fd::{AsRawFd, FromRawFd, RawFd};
|
||||||
@ -170,6 +170,10 @@ impl MagiskD {
|
|||||||
let module_fds: Vec<RawFd> = module_list
|
let module_fds: Vec<RawFd> = module_list
|
||||||
.iter()
|
.iter()
|
||||||
.map(|m| if is_64_bit { m.z64 } else { m.z32 })
|
.map(|m| if is_64_bit { m.z64 } else { m.z32 })
|
||||||
|
// All fds passed over sockets have to be valid file descriptors.
|
||||||
|
// To work around this issue, send over STDOUT_FILENO as an indicator of an
|
||||||
|
// invalid fd as it will always be /dev/null in magiskd.
|
||||||
|
.map(|fd| if fd < 0 { STDOUT_FILENO } else { fd })
|
||||||
.collect();
|
.collect();
|
||||||
client.send_fds(&module_fds)?;
|
client.send_fds(&module_fds)?;
|
||||||
}
|
}
|
||||||
@ -190,7 +194,11 @@ impl MagiskD {
|
|||||||
.join(&module_list[id as usize].name)
|
.join(&module_list[id as usize].name)
|
||||||
.join("zygisk");
|
.join("zygisk");
|
||||||
// Create the unloaded marker file
|
// Create the unloaded marker file
|
||||||
Directory::open(&path)?.open_fd(cstr!("unloaded"), O_CREAT | O_RDONLY, 0o644)?;
|
if let Ok(dir) = Directory::open(&path) {
|
||||||
|
dir.open_fd(cstr!("unloaded"), O_CREAT | O_RDONLY, 0o644)
|
||||||
|
.log()
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user