2017-03-18 16:52:38 +08:00
|
|
|
#include "magiskpolicy.h"
|
2017-04-15 19:26:29 +08:00
|
|
|
#include "sepolicy.h"
|
2017-02-01 00:51:45 +08:00
|
|
|
|
2018-11-08 04:20:16 -05:00
|
|
|
int sepol_allow(const char *s, const char *t, const char *c, const char *p) {
|
|
|
|
// printf("allow %s %s %s %s\n", s, t, c, p);
|
2017-02-04 06:36:15 +08:00
|
|
|
return add_rule(s, t, c, p, AVTAB_ALLOWED, 0);
|
2017-02-01 00:51:45 +08:00
|
|
|
}
|
|
|
|
|
2018-11-08 04:20:16 -05:00
|
|
|
int sepol_deny(const char *s, const char *t, const char *c, const char *p) {
|
2017-04-16 02:29:42 +08:00
|
|
|
// printf("deny %s %s %s %s\n", s, t, c, p);
|
2017-02-04 06:36:15 +08:00
|
|
|
return add_rule(s, t, c, p, AVTAB_ALLOWED, 1);
|
2017-02-01 00:51:45 +08:00
|
|
|
}
|
|
|
|
|
2018-11-08 04:20:16 -05:00
|
|
|
int sepol_auditallow(const char *s, const char *t, const char *c, const char *p) {
|
2017-04-16 02:29:42 +08:00
|
|
|
// printf("auditallow %s %s %s %s\n", s, t, c, p);
|
2017-02-04 06:36:15 +08:00
|
|
|
return add_rule(s, t, c, p, AVTAB_AUDITALLOW, 0);
|
2017-02-01 00:51:45 +08:00
|
|
|
}
|
|
|
|
|
2018-11-29 06:42:04 -05:00
|
|
|
int sepol_dontaudit(const char *s, const char *t, const char *c, const char *p) {
|
|
|
|
// printf("dontaudit %s %s %s %s\n", s, t, c, p);
|
2017-02-04 06:36:15 +08:00
|
|
|
return add_rule(s, t, c, p, AVTAB_AUDITDENY, 0);
|
2017-02-01 00:51:45 +08:00
|
|
|
}
|
|
|
|
|
2018-11-08 04:20:16 -05:00
|
|
|
int sepol_allowxperm(const char *s, const char *t, const char *c, const char *range) {
|
2017-04-20 04:04:09 +08:00
|
|
|
// printf("allowxperm %s %s %s %s\n", s, t, c, range);
|
|
|
|
return add_xperm_rule(s, t, c, range, AVTAB_XPERMS_ALLOWED, 0);
|
|
|
|
}
|
|
|
|
|
2018-11-08 04:20:16 -05:00
|
|
|
int sepol_auditallowxperm(const char *s, const char *t, const char *c, const char *range) {
|
2017-04-20 04:04:09 +08:00
|
|
|
// printf("auditallowxperm %s %s %s %s\n", s, t, c, range);
|
|
|
|
return add_xperm_rule(s, t, c, range, AVTAB_XPERMS_AUDITALLOW, 0);
|
|
|
|
}
|
|
|
|
|
2018-11-08 04:20:16 -05:00
|
|
|
int sepol_dontauditxperm(const char *s, const char *t, const char *c, const char *range) {
|
2017-04-20 04:04:09 +08:00
|
|
|
// printf("dontauditxperm %s %s %s %s\n", s, t, c, range);
|
|
|
|
return add_xperm_rule(s, t, c, range, AVTAB_XPERMS_DONTAUDIT, 0);
|
|
|
|
}
|
|
|
|
|
2018-11-29 03:46:29 -05:00
|
|
|
int sepol_typetrans(const char *s, const char *t, const char *c, const char *d) {
|
|
|
|
// printf("type_transition %s %s %s %s\n", s, t, c, d);
|
|
|
|
return add_type_rule(s, t, c, d, AVTAB_TRANSITION);
|
|
|
|
}
|
|
|
|
|
|
|
|
int sepol_typechange(const char *s, const char *t, const char *c, const char *d) {
|
|
|
|
// printf("type_change %s %s %s %s\n", s, t, c, d);
|
|
|
|
return add_type_rule(s, t, c, d, AVTAB_CHANGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int sepol_typemember(const char *s, const char *t, const char *c, const char *d) {
|
|
|
|
// printf("type_member %s %s %s %s\n", s, t, c, d);
|
|
|
|
return add_type_rule(s, t, c, d, AVTAB_MEMBER);
|
|
|
|
}
|
|
|
|
|
2018-11-08 04:20:16 -05:00
|
|
|
int sepol_permissive(const char *s) {
|
2017-04-16 02:29:42 +08:00
|
|
|
// printf("permissive %s\n", s);
|
2017-02-04 06:36:15 +08:00
|
|
|
return set_domain_state(s, 1);
|
2017-02-01 00:51:45 +08:00
|
|
|
}
|
|
|
|
|
2018-11-08 04:20:16 -05:00
|
|
|
int sepol_enforce(const char *s) {
|
2017-04-16 02:29:42 +08:00
|
|
|
// printf("enforce %s\n", s);
|
2017-02-04 06:36:15 +08:00
|
|
|
return set_domain_state(s, 0);
|
|
|
|
}
|
|
|
|
|
2018-11-08 04:20:16 -05:00
|
|
|
int sepol_create(const char *s) {
|
2017-04-16 02:29:42 +08:00
|
|
|
// printf("create %s\n", s);
|
2017-02-04 06:36:15 +08:00
|
|
|
return create_domain(s);
|
|
|
|
}
|
|
|
|
|
2018-11-08 04:20:16 -05:00
|
|
|
int sepol_attradd(const char *s, const char *a) {
|
2017-04-16 02:29:42 +08:00
|
|
|
// printf("attradd %s %s\n", s, a);
|
2017-02-04 06:36:15 +08:00
|
|
|
return add_typeattribute(s, a);
|
2017-02-01 00:51:45 +08:00
|
|
|
}
|
|
|
|
|
2018-11-08 04:20:16 -05:00
|
|
|
int sepol_exists(const char *source) {
|
|
|
|
return hashtab_search(policydb->p_types.table, source) != nullptr;
|
2017-02-01 00:51:45 +08:00
|
|
|
}
|