mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-28 23:00:47 +00:00
parent
c4847ed288
commit
9ddeab034b
@ -16,7 +16,7 @@ use logging::{android_logging, setup_logfile, zygisk_close_logd, zygisk_get_logd
|
|||||||
use mount::{find_preinit_device, revert_unmount};
|
use mount::{find_preinit_device, revert_unmount};
|
||||||
use resetprop::{persist_delete_prop, persist_get_prop, persist_get_props, persist_set_prop};
|
use resetprop::{persist_delete_prop, persist_get_prop, persist_get_props, persist_set_prop};
|
||||||
use socket::{recv_fd, recv_fds, send_fd, send_fds};
|
use socket::{recv_fd, recv_fds, send_fd, send_fds};
|
||||||
use su::{pump_stdin_stdout, get_pty_num, restore_stdin};
|
use su::{pump_tty, get_pty_num, restore_stdin};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::mem::ManuallyDrop;
|
use std::mem::ManuallyDrop;
|
||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
@ -209,7 +209,7 @@ pub mod ffi {
|
|||||||
#[namespace = "rust"]
|
#[namespace = "rust"]
|
||||||
fn daemon_entry();
|
fn daemon_entry();
|
||||||
|
|
||||||
fn pump_stdin_stdout(infd: i32, outfd: i32);
|
fn pump_tty(infd: i32, outfd: i32);
|
||||||
fn get_pty_num(fd: i32) -> i32;
|
fn get_pty_num(fd: i32) -> i32;
|
||||||
fn restore_stdin() -> bool;
|
fn restore_stdin() -> bool;
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,4 @@ mod db;
|
|||||||
mod pts;
|
mod pts;
|
||||||
|
|
||||||
pub use daemon::SuInfo;
|
pub use daemon::SuInfo;
|
||||||
pub use pts::{pump_stdin_stdout, get_pty_num, restore_stdin};
|
pub use pts::{pump_tty, get_pty_num, restore_stdin};
|
||||||
|
@ -28,10 +28,14 @@ fn set_stdin_raw() -> bool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let old_c_oflag = termios.c_oflag;
|
||||||
OLD_STDIN = Some(termios);
|
OLD_STDIN = Some(termios);
|
||||||
|
|
||||||
cfmakeraw(&mut termios);
|
cfmakeraw(&mut termios);
|
||||||
|
|
||||||
|
// don't modify output flags, since we are not setting stdout raw
|
||||||
|
termios.c_oflag = old_c_oflag;
|
||||||
|
|
||||||
if tcsetattr(STDIN_FILENO, TCSAFLUSH, &termios) < 0
|
if tcsetattr(STDIN_FILENO, TCSAFLUSH, &termios) < 0
|
||||||
&& tcsetattr(STDIN_FILENO, TCSADRAIN, &termios) < 0
|
&& tcsetattr(STDIN_FILENO, TCSADRAIN, &termios) < 0
|
||||||
{
|
{
|
||||||
@ -65,7 +69,7 @@ fn resize_pty(outfd: i32) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pump_stdin_stdout(infd: i32, outfd: i32) {
|
pub fn pump_tty(infd: i32, outfd: i32) {
|
||||||
set_stdin_raw();
|
set_stdin_raw();
|
||||||
|
|
||||||
let sfd = unsafe {
|
let sfd = unsafe {
|
||||||
@ -82,7 +86,7 @@ pub fn pump_stdin_stdout(infd: i32, outfd: i32) {
|
|||||||
|
|
||||||
let mut pfds = [
|
let mut pfds = [
|
||||||
pollfd {
|
pollfd {
|
||||||
fd: STDIN_FILENO,
|
fd: if outfd > 0 { STDIN_FILENO } else { -1 },
|
||||||
events: POLLIN,
|
events: POLLIN,
|
||||||
revents: 0,
|
revents: 0,
|
||||||
},
|
},
|
||||||
|
@ -239,7 +239,9 @@ int su_client_main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (atty) {
|
if (atty) {
|
||||||
setup_sighandlers(sighandler);
|
setup_sighandlers(sighandler);
|
||||||
pump_stdin_stdout(ptmx, ptmx);
|
// if stdin is not a tty, if we pump to ptmx, our process may intercept the input to ptmx and
|
||||||
|
// output to stdout, which cause the target process lost input.
|
||||||
|
pump_tty(ptmx, (atty & ATTY_IN) ? ptmx : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the exit code
|
// Get the exit code
|
||||||
|
Loading…
x
Reference in New Issue
Block a user