mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 16:27:39 +00:00
3dfcc6b0be
- Checkout from https://github.com/seSuperuser/Superuser (commit: 69f84dd7a035b4a9f18dea69d9e0452bf0f73103) - Move Superuser/Superuser/jni/su/* to root - Move Superuser/jni/sqlite3/* to sqlite3
50 lines
1.2 KiB
C
50 lines
1.2 KiB
C
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include "su.h"
|
|
#include "utils.h"
|
|
|
|
enum {
|
|
H_NO_CONTEXT = 0x0001,
|
|
};
|
|
|
|
static struct {
|
|
const char *package;
|
|
int flags;
|
|
int uid;
|
|
} apps_list[] = {
|
|
{ "com.keramidas.TitaniumBackup", H_NO_CONTEXT, },
|
|
};
|
|
|
|
void hacks_init() {
|
|
char oldCwd[512];
|
|
int i;
|
|
getcwd(oldCwd, sizeof(oldCwd));
|
|
chdir("/data/data");
|
|
for(i=0; i<(sizeof(apps_list)/sizeof(apps_list[0])); ++i) {
|
|
apps_list[i].uid = -1;
|
|
struct stat st_buf;
|
|
int ret = stat(apps_list[i].package, &st_buf);
|
|
LOGW("hacks: Testing (%s:%d:%d)", apps_list[i].package, ret, st_buf.st_uid);
|
|
if(ret)
|
|
continue;
|
|
apps_list[i].uid = st_buf.st_uid;
|
|
}
|
|
}
|
|
|
|
void hacks_update_context(struct su_context* ctxt) {
|
|
int i;
|
|
for(i=0; i<(sizeof(apps_list)/sizeof(apps_list[0])); ++i) {
|
|
LOGW("hacks: Testing (%s:%d), %d", apps_list[i].package, ctxt->from.uid);
|
|
if(apps_list[i].uid != ctxt->from.uid)
|
|
continue;
|
|
|
|
LOGW("hacks: Found app (%s:%d)", apps_list[i].package, ctxt->from.uid);
|
|
if(apps_list[i].flags & H_NO_CONTEXT) {
|
|
LOGW("hacks: Disabling context (%s:%d)", apps_list[i].package, ctxt->from.uid);
|
|
ctxt->to.context = NULL;
|
|
}
|
|
}
|
|
}
|