Skip to content

Commit

Permalink
Implement uid_on_allowlist for Magisk
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-TSNG committed Feb 28, 2023
1 parent ff2658f commit cce8e66
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions zygiskd/src/root_impl/magisk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,20 @@ pub fn get_magisk() -> Option<Version> {
}

pub fn uid_on_allowlist(uid: i32) -> bool {
// TODO: uid_on_allowlist
return false;
let output: Option<String> = Command::new("magisk")
.arg("--sqlite")
.arg("select uid from policies where policy=2")
.stdout(Stdio::piped())
.spawn().ok()
.and_then(|child| child.wait_with_output().ok())
.and_then(|output| String::from_utf8(output.stdout).ok());
let lines = match &output {
Some(output) => output.lines(),
None => return false,
};
lines.into_iter().any(|line| {
line.trim().strip_prefix("uid=").and_then(|uid| uid.parse().ok()) == Some(uid)
})
}

pub fn uid_on_denylist(uid: i32) -> bool {
Expand Down

0 comments on commit cce8e66

Please sign in to comment.