2017-03-18 08:52:38 +00:00
|
|
|
#include "magiskpolicy.h"
|
2017-04-15 11:26:29 +00:00
|
|
|
#include "sepolicy.h"
|
2017-01-31 16:51:45 +00:00
|
|
|
|
2017-04-15 11:26:29 +00:00
|
|
|
int sepol_allow(char *s, char *t, char *c, char *p) {
|
2017-04-15 18:29:42 +00:00
|
|
|
// printf("allow %s %s %s %s\n", s, t, c, p);
|
2017-02-03 22:36:15 +00:00
|
|
|
return add_rule(s, t, c, p, AVTAB_ALLOWED, 0);
|
2017-01-31 16:51:45 +00:00
|
|
|
}
|
|
|
|
|
2017-04-15 11:26:29 +00:00
|
|
|
int sepol_deny(char *s, char *t, char *c, char *p) {
|
2017-04-15 18:29:42 +00:00
|
|
|
// printf("deny %s %s %s %s\n", s, t, c, p);
|
2017-02-03 22:36:15 +00:00
|
|
|
return add_rule(s, t, c, p, AVTAB_ALLOWED, 1);
|
2017-01-31 16:51:45 +00:00
|
|
|
}
|
|
|
|
|
2017-04-15 11:26:29 +00:00
|
|
|
int sepol_auditallow(char *s, char *t, char *c, char *p) {
|
2017-04-15 18:29:42 +00:00
|
|
|
// printf("auditallow %s %s %s %s\n", s, t, c, p);
|
2017-02-03 22:36:15 +00:00
|
|
|
return add_rule(s, t, c, p, AVTAB_AUDITALLOW, 0);
|
2017-01-31 16:51:45 +00:00
|
|
|
}
|
|
|
|
|
2017-04-15 11:26:29 +00:00
|
|
|
int sepol_auditdeny(char *s, char *t, char *c, char *p) {
|
2017-04-15 18:29:42 +00:00
|
|
|
// printf("auditdeny %s %s %s %s\n", s, t, c, p);
|
2017-02-03 22:36:15 +00:00
|
|
|
return add_rule(s, t, c, p, AVTAB_AUDITDENY, 0);
|
2017-01-31 16:51:45 +00:00
|
|
|
}
|
|
|
|
|
2017-04-15 11:26:29 +00:00
|
|
|
int sepol_typetrans(char *s, char *t, char *c, char *d, char *o) {
|
2017-04-15 18:29:42 +00:00
|
|
|
if (o == NULL) {
|
|
|
|
// printf("add_trans %s %s %s %s\n", s, t, c ,d);
|
2017-02-03 22:36:15 +00:00
|
|
|
return add_transition(s, t, c, d);
|
2017-04-15 18:29:42 +00:00
|
|
|
} else {
|
|
|
|
// printf("add_file_trans %s %s %s %s %s\n", s, t, c ,d, o);
|
2017-02-03 22:36:15 +00:00
|
|
|
return add_file_transition(s, t, c, d, o);
|
2017-04-15 18:29:42 +00:00
|
|
|
}
|
2017-01-31 16:51:45 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 20:04:09 +00:00
|
|
|
int sepol_allowxperm(char *s, char *t, char *c, char *range) {
|
|
|
|
// printf("allowxperm %s %s %s %s\n", s, t, c, range);
|
|
|
|
return add_xperm_rule(s, t, c, range, AVTAB_XPERMS_ALLOWED, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int sepol_auditallowxperm(char *s, char *t, char *c, char *range) {
|
|
|
|
// printf("auditallowxperm %s %s %s %s\n", s, t, c, range);
|
|
|
|
return add_xperm_rule(s, t, c, range, AVTAB_XPERMS_AUDITALLOW, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int sepol_dontauditxperm(char *s, char *t, char *c, char *range) {
|
|
|
|
// printf("dontauditxperm %s %s %s %s\n", s, t, c, range);
|
|
|
|
return add_xperm_rule(s, t, c, range, AVTAB_XPERMS_DONTAUDIT, 0);
|
|
|
|
}
|
|
|
|
|
2017-04-15 11:26:29 +00:00
|
|
|
int sepol_permissive(char *s) {
|
2017-04-15 18:29:42 +00:00
|
|
|
// printf("permissive %s\n", s);
|
2017-02-03 22:36:15 +00:00
|
|
|
return set_domain_state(s, 1);
|
2017-01-31 16:51:45 +00:00
|
|
|
}
|
|
|
|
|
2017-04-15 11:26:29 +00:00
|
|
|
int sepol_enforce(char *s) {
|
2017-04-15 18:29:42 +00:00
|
|
|
// printf("enforce %s\n", s);
|
2017-02-03 22:36:15 +00:00
|
|
|
return set_domain_state(s, 0);
|
|
|
|
}
|
|
|
|
|
2017-04-15 11:26:29 +00:00
|
|
|
int sepol_create(char *s) {
|
2017-04-15 18:29:42 +00:00
|
|
|
// printf("create %s\n", s);
|
2017-02-03 22:36:15 +00:00
|
|
|
return create_domain(s);
|
|
|
|
}
|
|
|
|
|
2017-04-15 11:26:29 +00:00
|
|
|
int sepol_attradd(char *s, char *a) {
|
2017-04-15 18:29:42 +00:00
|
|
|
// printf("attradd %s %s\n", s, a);
|
2017-02-03 22:36:15 +00:00
|
|
|
return add_typeattribute(s, a);
|
2017-01-31 16:51:45 +00:00
|
|
|
}
|
|
|
|
|
2017-04-15 11:26:29 +00:00
|
|
|
int sepol_exists(char* source) {
|
2017-04-15 18:29:42 +00:00
|
|
|
return !! hashtab_search(policydb->p_types.table, source);
|
2017-01-31 16:51:45 +00:00
|
|
|
}
|