Revert "kernel: add package whitelist check for manager APKs"
This commit is contained in:
@@ -327,31 +327,7 @@ module_param_cb(ksu_debug_manager_uid, &expected_size_ops,
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define MANAGERPKG_WLSIZE 3
|
||||
static const char *manager_package_whitelist[] = {
|
||||
"zako.zako.zako",
|
||||
"com.sukisu.ultra",
|
||||
"me.weishu.kernelsu"
|
||||
};
|
||||
|
||||
bool is_package_whitelisted(char *package) {
|
||||
int i;
|
||||
for (i = 0; i < MANAGERPKG_WLSIZE; i ++) {
|
||||
const char* expected = manager_package_whitelist[i];
|
||||
if (strcmp(expected, package) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_manager_apk(char *path, char *package) {
|
||||
if (!is_package_whitelisted(package)) {
|
||||
pr_info("refused to crown %s (not in whitelist)", package);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_manager_apk(char *path)
|
||||
{
|
||||
return check_v2_signature(path);
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
bool is_manager_apk(char *path, char *package);
|
||||
|
||||
bool is_package_whitelisted(char *package);
|
||||
bool is_manager_apk(char *path);
|
||||
|
||||
#endif
|
||||
@@ -62,8 +62,14 @@ static int get_pkg_from_apk_path(char *pkg, const char *path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void crown_manager(const char *apk, char *pkg, struct list_head *uid_data)
|
||||
static void crown_manager(const char *apk, struct list_head *uid_data)
|
||||
{
|
||||
char pkg[KSU_MAX_PACKAGE_NAME];
|
||||
if (get_pkg_from_apk_path(pkg, apk) < 0) {
|
||||
pr_err("Failed to get package name from apk path: %s\n", apk);
|
||||
return;
|
||||
}
|
||||
|
||||
pr_info("manager pkg: %s\n", pkg);
|
||||
|
||||
#ifdef KSU_MANAGER_PACKAGE
|
||||
@@ -170,7 +176,6 @@ FILLDIR_RETURN_TYPE my_actor(struct dir_context *ctx, const char *name,
|
||||
} else {
|
||||
if ((namelen == 8) && (strncmp(name, "base.apk", namelen) == 0)) {
|
||||
struct apk_path_hash *pos;
|
||||
char pkg[KSU_MAX_PACKAGE_NAME];
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
|
||||
unsigned int hash = full_name_hash(dirpath, strlen(dirpath));
|
||||
#else
|
||||
@@ -183,16 +188,11 @@ FILLDIR_RETURN_TYPE my_actor(struct dir_context *ctx, const char *name,
|
||||
}
|
||||
}
|
||||
|
||||
if (get_pkg_from_apk_path(pkg, dirpath) < 0) {
|
||||
pr_err("Failed to get package name from apk path: %s\n", dirpath);
|
||||
return FILLDIR_ACTOR_CONTINUE;
|
||||
}
|
||||
|
||||
bool is_manager = is_manager_apk(dirpath, pkg);
|
||||
bool is_manager = is_manager_apk(dirpath);
|
||||
pr_info("Found new base.apk at path: %s, is_manager: %d\n",
|
||||
dirpath, is_manager);
|
||||
if (is_manager) {
|
||||
crown_manager(dirpath, pkg, my_ctx->private_data);
|
||||
crown_manager(dirpath, my_ctx->private_data);
|
||||
*my_ctx->stop = 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user