su: allocate new pty (#1693)

This commit is contained in:
5ec1cff
2024-05-07 19:02:59 +08:00
committed by GitHub
parent f2816653d9
commit 935dc18faa
8 changed files with 233 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
use anyhow::{Ok, Result};
use clap::Parser;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
#[cfg(target_os = "android")]
use android_logger::Config;
@@ -283,7 +283,7 @@ pub fn run() -> Result<()> {
// 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" {
if Path::new(&arg0).file_name().and_then(|f| f.to_str()) == Some("su") {
return crate::su::root_shell();
}