Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
cd498711
Commit
cd498711
authored
Apr 04, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjustments for unified binary
parent
dc9670c4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
39 deletions
+19
-39
Android.mk
Android.mk
+3
-3
magiskpolicy.c
magiskpolicy.c
+14
-4
magiskpolicy.h
magiskpolicy.h
+2
-10
utils.c
utils.c
+0
-22
No files found.
Android.mk
View file @
cd498711
...
@@ -3,9 +3,9 @@ LOCAL_PATH := $(call my-dir)
...
@@ -3,9 +3,9 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include $(CLEAR_VARS)
LOCAL_MODULE := magiskpolicy
LOCAL_MODULE := magiskpolicy
LOCAL_STATIC_LIBRARIES := libsepol
LOCAL_STATIC_LIBRARIES := libsepol
LOCAL_SRC_FILES := ma
in.c sepolicy.c rules.c utils
.c
LOCAL_SRC_FILES := ma
giskpolicy.c sepolicy.c rules.c utils.c ../utils/vector
.c
LOCAL_C_INCLUDES := jni/selinux/libsepol/include
/
LOCAL_C_INCLUDES := jni/selinux/libsepol/include
jni/utils
LOCAL_CFLAGS
+= -std=gnu11
LOCAL_CFLAGS
:= -DINDEP_BINARY
include $(BUILD_EXECUTABLE)
include $(BUILD_EXECUTABLE)
include jni/selinux/libsepol/Android.mk
include jni/selinux/libsepol/Android.mk
ma
in
.c
→
ma
giskpolicy
.c
View file @
cd498711
#include "vector.h"
#include "magiskpolicy.h"
#include "magiskpolicy.h"
#ifdef INDEP_BINARY
int
magiskpolicy_main
(
int
argc
,
char
*
argv
[]);
int
main
(
int
argc
,
char
*
argv
[])
{
return
magiskpolicy_main
(
argc
,
argv
);
}
#else
#include "magisk.h"
#endif
static
int
syntax_err
=
0
;
static
int
syntax_err
=
0
;
static
char
err_msg
[
ARG_MAX
];
static
char
err_msg
[
ARG_MAX
];
...
@@ -52,7 +62,7 @@ static void usage(char *arg0) {
...
@@ -52,7 +62,7 @@ static void usage(char *arg0) {
static
int
parse_pattern_1
(
int
action
,
char
*
statement
)
{
static
int
parse_pattern_1
(
int
action
,
char
*
statement
)
{
int
state
=
0
,
in_bracket
=
0
;
int
state
=
0
,
in_bracket
=
0
;
char
*
tok
,
*
class
,
*
saveptr
;
char
*
tok
,
*
class
,
*
saveptr
;
vector
source
,
target
,
permission
,
*
temp
;
struct
vector
source
,
target
,
permission
,
*
temp
;
vec_init
(
&
source
);
vec_init
(
&
source
);
vec_init
(
&
target
);
vec_init
(
&
target
);
vec_init
(
&
permission
);
vec_init
(
&
permission
);
...
@@ -130,7 +140,7 @@ static int parse_pattern_1(int action, char* statement) {
...
@@ -130,7 +140,7 @@ static int parse_pattern_1(int action, char* statement) {
static
int
parse_pattern_2
(
int
action
,
char
*
statement
)
{
static
int
parse_pattern_2
(
int
action
,
char
*
statement
)
{
int
state
=
0
,
in_bracket
=
0
;
int
state
=
0
,
in_bracket
=
0
;
char
*
tok
,
*
saveptr
;
char
*
tok
,
*
saveptr
;
vector
class
,
attribute
,
*
temp
;
struct
vector
class
,
attribute
,
*
temp
;
vec_init
(
&
class
);
vec_init
(
&
class
);
vec_init
(
&
attribute
);
vec_init
(
&
attribute
);
tok
=
strtok_r
(
statement
,
" "
,
&
saveptr
);
tok
=
strtok_r
(
statement
,
" "
,
&
saveptr
);
...
@@ -185,7 +195,7 @@ static int parse_pattern_2(int action, char* statement) {
...
@@ -185,7 +195,7 @@ static int parse_pattern_2(int action, char* statement) {
// Pattern 3: action { type }
// Pattern 3: action { type }
static
int
parse_pattern_3
(
int
action
,
char
*
statement
)
{
static
int
parse_pattern_3
(
int
action
,
char
*
statement
)
{
char
*
tok
,
*
saveptr
;
char
*
tok
,
*
saveptr
;
vector
classes
;
struct
vector
classes
;
vec_init
(
&
classes
);
vec_init
(
&
classes
);
tok
=
strtok_r
(
statement
,
" {}"
,
&
saveptr
);
tok
=
strtok_r
(
statement
,
" {}"
,
&
saveptr
);
while
(
tok
!=
NULL
)
{
while
(
tok
!=
NULL
)
{
...
@@ -253,7 +263,7 @@ static void syntax_error_msg() {
...
@@ -253,7 +263,7 @@ static void syntax_error_msg() {
syntax_err
=
1
;
syntax_err
=
1
;
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
ma
giskpolicy_ma
in
(
int
argc
,
char
*
argv
[])
{
char
*
infile
=
NULL
,
*
outfile
=
NULL
,
*
tok
,
*
saveptr
;
char
*
infile
=
NULL
,
*
outfile
=
NULL
,
*
tok
,
*
saveptr
;
int
live
=
0
,
minimal
=
0
,
full
=
0
;
int
live
=
0
,
minimal
=
0
,
full
=
0
;
struct
vector
rules
;
struct
vector
rules
;
...
...
magiskpolicy.h
View file @
cd498711
...
@@ -22,6 +22,8 @@
...
@@ -22,6 +22,8 @@
#include <sepol/policydb/conditional.h>
#include <sepol/policydb/conditional.h>
#include <sepol/policydb/constraint.h>
#include <sepol/policydb/constraint.h>
#include "vector.h"
// hashtab traversal macro
// hashtab traversal macro
#define hashtab_for_each(table, ptr) \
#define hashtab_for_each(table, ptr) \
for (int _i = 0; _i < table->size; ++_i) \
for (int _i = 0; _i < table->size; ++_i) \
...
@@ -52,16 +54,6 @@ int enforce(char *s);
...
@@ -52,16 +54,6 @@ int enforce(char *s);
int
attradd
(
char
*
s
,
char
*
a
);
int
attradd
(
char
*
s
,
char
*
a
);
int
exists
(
char
*
source
);
int
exists
(
char
*
source
);
// Vector of char*
typedef
struct
vector
{
size_t
size
;
size_t
cap
;
char
**
data
;
}
vector
;
void
vec_init
(
vector
*
v
);
void
vec_push_back
(
vector
*
v
,
char
*
s
);
void
vec_destroy
(
vector
*
v
);
// Built in rules
// Built in rules
void
full_rules
();
void
full_rules
();
void
min_rules
();
void
min_rules
();
...
...
utils.c
View file @
cd498711
#include "magiskpolicy.h"
#include "magiskpolicy.h"
void
vec_init
(
vector
*
v
)
{
v
->
size
=
0
;
v
->
cap
=
1
;
v
->
data
=
(
char
**
)
malloc
(
sizeof
(
char
*
));
}
void
vec_push_back
(
vector
*
v
,
char
*
s
)
{
if
(
v
==
NULL
)
return
;
if
(
v
->
size
==
v
->
cap
)
{
v
->
cap
*=
2
;
v
->
data
=
(
char
**
)
realloc
(
v
->
data
,
sizeof
(
char
*
)
*
v
->
cap
);
}
v
->
data
[
v
->
size
]
=
s
;
++
v
->
size
;
}
void
vec_destroy
(
vector
*
v
)
{
v
->
size
=
0
;
v
->
cap
=
0
;
free
(
v
->
data
);
}
int
allow
(
char
*
s
,
char
*
t
,
char
*
c
,
char
*
p
)
{
int
allow
(
char
*
s
,
char
*
t
,
char
*
c
,
char
*
p
)
{
return
add_rule
(
s
,
t
,
c
,
p
,
AVTAB_ALLOWED
,
0
);
return
add_rule
(
s
,
t
,
c
,
p
,
AVTAB_ALLOWED
,
0
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment