mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-06-12 13:17:39 +02:00
Application Component Granularity MagiskHide
Before switching to the new MagiskHide implementation (APK inotify), logcat parsing provides us lots of information to target a process. We were targeting components so that apps with multi-processes can still be hidden properly. After switching to the new implementation, our granularity is limited to the UID of the process. This is especially dangerous since Android allow apps signed with the same signature to share UIDs, and many system apps utilize this for elevated permissions for some services. This commit introduces process name matching. We could not blanketly target an UID, so the workaround is to verify its process name before unmounting. The tricky thing is that any app developer is allowed to name the process of its component to whatever they want; there is no 'one rule to catch them all' to target a specific package. As a result, Magisk Manager is updated to scan through all components of all apps, and show different processes of the same app, each as a separate hide target in the list. The hide target database also has to be updated accordingly. Each hide target is now a <package name, process name> pair. The magiskhide CLI and Magisk Manager is updated to support this new target format.
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
#include <db.h>
|
||||
#include <daemon.h>
|
||||
|
||||
#define DB_VERSION 7
|
||||
#define DB_VERSION 8
|
||||
|
||||
static sqlite3 *mDB = nullptr;
|
||||
|
||||
@ -86,7 +86,8 @@ static char *open_and_init_db(sqlite3 *&db) {
|
||||
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, nullptr);
|
||||
if (ret)
|
||||
return strdup(sqlite3_errmsg(db));
|
||||
int ver, upgrade = 0;
|
||||
int ver;
|
||||
bool upgrade = false;
|
||||
char *err;
|
||||
sqlite3_exec(db, "PRAGMA user_version", ver_cb, &ver, &err);
|
||||
err_ret(err);
|
||||
@ -117,9 +118,9 @@ static char *open_and_init_db(sqlite3 *&db) {
|
||||
nullptr, nullptr, &err);
|
||||
err_ret(err);
|
||||
ver = 3;
|
||||
upgrade = 1;
|
||||
upgrade = true;
|
||||
}
|
||||
if (ver == 3) {
|
||||
if (ver < 4) {
|
||||
// Strings
|
||||
sqlite3_exec(db,
|
||||
"CREATE TABLE IF NOT EXISTS strings "
|
||||
@ -127,16 +128,16 @@ static char *open_and_init_db(sqlite3 *&db) {
|
||||
nullptr, nullptr, &err);
|
||||
err_ret(err);
|
||||
ver = 4;
|
||||
upgrade = 1;
|
||||
upgrade = true;
|
||||
}
|
||||
if (ver == 4) {
|
||||
if (ver < 5) {
|
||||
sqlite3_exec(db, "UPDATE policies SET uid=uid%100000", nullptr, nullptr, &err);
|
||||
err_ret(err);
|
||||
/* Skip version 5 */
|
||||
ver = 6;
|
||||
upgrade = 1;
|
||||
upgrade = true;
|
||||
}
|
||||
if (ver == 5 || ver == 6) {
|
||||
if (ver < 7) {
|
||||
// Hide list
|
||||
sqlite3_exec(db,
|
||||
"CREATE TABLE IF NOT EXISTS hidelist "
|
||||
@ -144,7 +145,17 @@ static char *open_and_init_db(sqlite3 *&db) {
|
||||
nullptr, nullptr, &err);
|
||||
err_ret(err);
|
||||
ver = 7;
|
||||
upgrade =1 ;
|
||||
upgrade = true;
|
||||
}
|
||||
if (ver < 8) {
|
||||
sqlite3_exec(db,
|
||||
"ALTER TABLE hidelist ADD COLUMN package_name TEXT;"
|
||||
"SELECT process FROM hidelist;"
|
||||
"UPDATE hidelist SET package_name=process;",
|
||||
nullptr, nullptr, &err);
|
||||
err_ret(err);
|
||||
ver = 8;
|
||||
upgrade = true;
|
||||
}
|
||||
|
||||
if (upgrade) {
|
||||
|
Reference in New Issue
Block a user