mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-28 12:35:26 +00:00
Add --magisk option
This commit is contained in:
parent
0cfc527328
commit
03c8079858
@ -63,7 +63,7 @@ void vec_push_back(vector *v, char* s);
|
|||||||
void vec_destroy(vector *v);
|
void vec_destroy(vector *v);
|
||||||
|
|
||||||
// Built in rules
|
// Built in rules
|
||||||
void su_rules();
|
void full_rules();
|
||||||
void min_rules();
|
void min_rules();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
21
main.c
21
main.c
@ -34,9 +34,16 @@ static void statements() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void usage(char *arg0) {
|
static void usage(char *arg0) {
|
||||||
fprintf(stderr, "%s [--live] [--minimal] [--load <infile>] [--save <outfile>] [policystatement...]\n\n", arg0);
|
fprintf(stderr,
|
||||||
fprintf(stderr, " --live: directly load patched policy to device\n");
|
"%s [--options...] [policystatements...]\n\n"
|
||||||
fprintf(stderr, " --minimal: minimal patches for boot image to let Magisk live patch on boot\n");
|
"Options:\n"
|
||||||
|
" --live: directly load patched policy to device\n"
|
||||||
|
" --magisk: complete (very large!) patches for Magisk and MagiskSU\n"
|
||||||
|
" --minimal: minimal patches, used for boot image patches\n"
|
||||||
|
" --load <infile>: load policies from <infile>\n"
|
||||||
|
" (load from current policies if not specified)"
|
||||||
|
" --save <outfile>: save policies to <outfile>\n"
|
||||||
|
, arg0);
|
||||||
statements();
|
statements();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -248,7 +255,7 @@ static void syntax_error_msg() {
|
|||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
char *infile = NULL, *outfile = NULL, *tok, *saveptr;
|
char *infile = NULL, *outfile = NULL, *tok, *saveptr;
|
||||||
int live = 0, minimal = 0;
|
int live = 0, minimal = 0, full = 0;
|
||||||
struct vector rules;
|
struct vector rules;
|
||||||
|
|
||||||
vec_init(&rules);
|
vec_init(&rules);
|
||||||
@ -258,6 +265,8 @@ int main(int argc, char *argv[]) {
|
|||||||
if (argv[i][0] == '-' && argv[i][1] == '-') {
|
if (argv[i][0] == '-' && argv[i][1] == '-') {
|
||||||
if (strcmp(argv[i], "--live") == 0)
|
if (strcmp(argv[i], "--live") == 0)
|
||||||
live = 1;
|
live = 1;
|
||||||
|
else if (strcmp(argv[i], "--magisk") == 0)
|
||||||
|
full = 1;
|
||||||
else if (strcmp(argv[i], "--minimal") == 0)
|
else if (strcmp(argv[i], "--minimal") == 0)
|
||||||
minimal = 1;
|
minimal = 1;
|
||||||
else if (strcmp(argv[i], "--load") == 0) {
|
else if (strcmp(argv[i], "--load") == 0) {
|
||||||
@ -294,8 +303,8 @@ int main(int argc, char *argv[]) {
|
|||||||
if (policydb_load_isids(&policydb, &sidtab))
|
if (policydb_load_isids(&policydb, &sidtab))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!minimal && rules.size == 0) su_rules();
|
if (full) full_rules();
|
||||||
if (minimal) min_rules();
|
else if (minimal) min_rules();
|
||||||
|
|
||||||
for (int i = 0; i < rules.size; ++i) {
|
for (int i = 0; i < rules.size; ++i) {
|
||||||
// Since strtok will modify the origin string, copy the policy for error messages
|
// Since strtok will modify the origin string, copy the policy for error messages
|
||||||
|
2
rules.c
2
rules.c
@ -129,7 +129,7 @@ void otherToSU() {
|
|||||||
allow("audioserver", "audioserver", "process", "execmem");
|
allow("audioserver", "audioserver", "process", "execmem");
|
||||||
}
|
}
|
||||||
|
|
||||||
void su_rules() {
|
void full_rules() {
|
||||||
// Samsung specific
|
// Samsung specific
|
||||||
// Prevent system from loading policy
|
// Prevent system from loading policy
|
||||||
if(exists("knox_system_app"))
|
if(exists("knox_system_app"))
|
||||||
|
Loading…
Reference in New Issue
Block a user