ksud: enter root shell when arg0 equals su

This commit is contained in:
tiann 2023-04-03 20:28:13 +08:00
parent ed0e9cff4b
commit bdd5e31b6f
No known key found for this signature in database
GPG Key ID: 6D3F65FFD9559C06

View File

@ -138,6 +138,12 @@ pub fn run() -> Result<()> {
#[cfg(not(target_os = "android"))]
env_logger::init();
// the kernel executes su with argv[0] = "su" and replace it with us
let arg0 = std::env::args().next().unwrap_or_default();
if arg0 == "su" || arg0 == "/system/bin/su" {
return crate::ksu::grant_root();
}
let cli = Args::parse();
log::info!("command: {:?}", cli.command);