From bdd5e31b6f75f276f482e081e155b4fcc76641cc Mon Sep 17 00:00:00 2001 From: tiann Date: Mon, 3 Apr 2023 20:28:13 +0800 Subject: [PATCH] ksud: enter root shell when arg0 equals su --- userspace/ksud/src/cli.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/userspace/ksud/src/cli.rs b/userspace/ksud/src/cli.rs index 51772305..977056b1 100644 --- a/userspace/ksud/src/cli.rs +++ b/userspace/ksud/src/cli.rs @@ -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);