ksud: support set-manager (#114)

* ksud: support set-manager

* ksud: rework apk sign

Co-authored-by: Ylarod <me@ylarod.cn>
This commit is contained in:
weishu
2023-01-25 17:55:08 +08:00
committed by GitHub
parent 47a736f567
commit 64d78c31bc
4 changed files with 200 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
use anyhow::Result;
use clap::Parser;
use crate::{event, module};
use crate::{event, module, debug, apk_sign};
/// KernelSU userspace cli
#[derive(Parser, Debug)]
@@ -37,7 +37,27 @@ enum Commands {
/// SELinux policy Patch tool
Sepolicy,
/// For test
/// For developers
Debug {
#[command(subcommand)]
command: Debug,
},
}
#[derive(clap::Subcommand, Debug)]
enum Debug {
/// Set the manager app, kernel CONFIG_KSU_DEBUG should be enabled.
SetManager {
/// manager apk path or package name
apk: String,
},
/// Get apk size and hash
GetSign {
/// apk path
apk: String,
},
/// For testing
Test,
}
@@ -93,7 +113,18 @@ pub fn run() -> Result<()> {
Commands::Install => event::install(),
Commands::Sepolicy => todo!(),
Commands::Services => event::on_services(),
Commands::Test => event::do_systemless_mount("/data/adb/ksu/modules"),
Commands::Debug { command } => {
match command {
Debug::SetManager { apk } => debug::set_manager(&apk),
Debug::GetSign { apk } => {
let sign = apk_sign::get_apk_signature(&apk)?;
println!("size: {:#x}, hash: {:#x}", sign.0, sign.1);
Ok(())
},
Debug::Test => todo!(),
}
}
};
if let Err(e) = &result {