You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
+20
-7
@@ -246,28 +246,41 @@ int get_uid_policy(su_access &su, int uid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int validate_manager(string &alt_pkg, int userid, struct stat *st) {
|
||||
bool check_manager(string *pkg) {
|
||||
db_strings str;
|
||||
get_db_strings(str, SU_MANAGER);
|
||||
bool ret = validate_manager(str[SU_MANAGER], 0, nullptr);
|
||||
if (pkg) {
|
||||
if (ret)
|
||||
pkg->swap(str[SU_MANAGER]);
|
||||
else
|
||||
*pkg = "xxx"; /* Make sure the return pkg can never exist */
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool validate_manager(string &pkg, int userid, struct stat *st) {
|
||||
struct stat tmp_st;
|
||||
if (st == nullptr)
|
||||
st = &tmp_st;
|
||||
|
||||
// Prefer DE storage
|
||||
char app_path[128];
|
||||
sprintf(app_path, "%s/%d/%s", APP_DATA_DIR, userid, alt_pkg.empty() ? "xxx" : alt_pkg.data());
|
||||
if (stat(app_path, st)) {
|
||||
sprintf(app_path, "%s/%d/%s", APP_DATA_DIR, userid, pkg.data());
|
||||
if (pkg.empty() || stat(app_path, st)) {
|
||||
// Check the official package name
|
||||
sprintf(app_path, "%s/%d/" JAVA_PACKAGE_NAME, APP_DATA_DIR, userid);
|
||||
if (stat(app_path, st)) {
|
||||
LOGE("su: cannot find manager");
|
||||
memset(st, 0, sizeof(*st));
|
||||
alt_pkg.clear();
|
||||
return 1;
|
||||
pkg.clear();
|
||||
return false;
|
||||
} else {
|
||||
// Switch to official package if exists
|
||||
alt_pkg = JAVA_PACKAGE_NAME;
|
||||
pkg = JAVA_PACKAGE_NAME;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void exec_sql(int client) {
|
||||
|
||||
Reference in New Issue
Block a user