ksud: support .ksurc (#345)

This commit is contained in:
Ylarod
2023-04-05 13:30:21 +08:00
committed by GitHub
parent b181147922
commit c96b0e8f8b
4 changed files with 8 additions and 0 deletions

View File

@@ -1 +1,2 @@
/target
.cargo/

View File

@@ -4,6 +4,7 @@ pub const ADB_DIR: &str = "/data/adb/";
pub const WORKING_DIR: &str = concatcp!(ADB_DIR, "ksu/");
pub const BINARY_DIR: &str = concatcp!(WORKING_DIR, "bin/");
pub const KSURC_PATH: &str = concatcp!(WORKING_DIR, ".ksurc");
pub const DAEMON_PATH: &str = concatcp!(ADB_DIR, "ksud");
#[cfg(target_os = "android")]

View File

@@ -214,6 +214,11 @@ pub fn root_shell() -> Result<()> {
#[cfg(any(target_os = "linux", target_os = "android"))]
add_path_to_env(defs::BINARY_DIR)?;
// when KSURC_PATH exists and ENV is not set, set ENV to KSURC_PATH
if PathBuf::from(defs::KSURC_PATH).exists() && env::var("ENV").is_err() {
command = command.env("ENV", defs::KSURC_PATH);
}
// escape from the current cgroup and become session leader
// WARNING!!! This cause some root shell hang forever!
// command = command.process_group(0);