mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-15 18:10:23 +00:00
Cleanup headers
This commit is contained in:
@@ -51,6 +51,11 @@ int sepol_typemember(const char *s, const char *t, const char *c, const char *d)
|
||||
return add_type_rule(s, t, c, d, AVTAB_MEMBER);
|
||||
}
|
||||
|
||||
int sepol_nametrans(const char *s, const char *t, const char *c, const char *d, const char *o) {
|
||||
// printf("name_trans %s %s %s %s %s\n", s, t, c, d, o);
|
||||
return add_filename_trans(s, t, c, d, o);
|
||||
}
|
||||
|
||||
int sepol_permissive(const char *s) {
|
||||
// printf("permissive %s\n", s);
|
||||
return set_domain_state(s, 1);
|
||||
|
@@ -8,8 +8,6 @@
|
||||
|
||||
#define ALL NULL
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
// policydb functions
|
||||
int load_policydb(const char *file);
|
||||
int load_split_cil();
|
||||
@@ -37,5 +35,3 @@ int sepol_exists(const char *source);
|
||||
|
||||
// Built in rules
|
||||
void sepol_magisk_rules();
|
||||
|
||||
__END_DECLS
|
||||
|
@@ -1,12 +1,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <sepol/policydb/expand.h>
|
||||
|
||||
#include <utils.h>
|
||||
#include <logging.h>
|
||||
|
||||
#include "magiskpolicy.h"
|
||||
#include "sepolicy.h"
|
||||
|
||||
extern void *xmalloc(size_t size);
|
||||
extern void *xcalloc(size_t nmemb, size_t size);
|
||||
extern void *xrealloc(void *ptr, size_t size);
|
||||
extern int policydb_index_decls(sepol_handle_t * handle, policydb_t * p);
|
||||
|
||||
static int get_attr(const char *type, int value) {
|
||||
@@ -39,9 +40,9 @@ static int set_attr(const char *type, int value) {
|
||||
if (attr->flavor != TYPE_ATTRIB)
|
||||
return 1;
|
||||
|
||||
if(ebitmap_set_bit(&policydb->type_attr_map[value-1], attr->s.value-1, 1))
|
||||
if(ebitmap_set_bit(&policydb->type_attr_map[value - 1], attr->s.value - 1, 1))
|
||||
return 1;
|
||||
if(ebitmap_set_bit(&policydb->attr_type_map[attr->s.value-1], value-1, 1))
|
||||
if(ebitmap_set_bit(&policydb->attr_type_map[attr->s.value - 1], value - 1, 1))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
@@ -223,7 +224,7 @@ int create_domain(const char *d) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
type_datum_t *typedatum = (type_datum_t *) malloc(sizeof(type_datum_t));
|
||||
type_datum_t *typedatum = (type_datum_t *) xmalloc(sizeof(type_datum_t));
|
||||
type_datum_init(typedatum);
|
||||
typedatum->primary = 1;
|
||||
typedatum->flavor = TYPE_TYPE;
|
||||
@@ -236,8 +237,8 @@ int create_domain(const char *d) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
policydb->type_attr_map = realloc(policydb->type_attr_map, sizeof(ebitmap_t) * policydb->p_types.nprim);
|
||||
policydb->attr_type_map = realloc(policydb->attr_type_map, sizeof(ebitmap_t) * policydb->p_types.nprim);
|
||||
policydb->type_attr_map = xrealloc(policydb->type_attr_map, sizeof(ebitmap_t) * policydb->p_types.nprim);
|
||||
policydb->attr_type_map = xrealloc(policydb->attr_type_map, sizeof(ebitmap_t) * policydb->p_types.nprim);
|
||||
ebitmap_init(&policydb->type_attr_map[value-1]);
|
||||
ebitmap_init(&policydb->attr_type_map[value-1]);
|
||||
ebitmap_set_bit(&policydb->type_attr_map[value-1], value-1, 1);
|
||||
@@ -292,7 +293,7 @@ int set_domain_state(const char *s, int state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sepol_nametrans(const char *s, const char *t, const char *c, const char *d, const char *o) {
|
||||
int add_filename_trans(const char *s, const char *t, const char *c, const char *d, const char *o) {
|
||||
type_datum_t *src, *tgt, *def;
|
||||
class_datum_t *cls;
|
||||
|
||||
@@ -350,12 +351,12 @@ int add_typeattribute(const char *domainS, const char *attr) {
|
||||
int typeId = get_attr_id(attr);
|
||||
//Now let's update all constraints!
|
||||
//(kernel doesn't support (yet?) type_names rules)
|
||||
for(int i=0; i<policydb->p_classes.nprim; ++i) {
|
||||
for(int i = 0; i < policydb->p_classes.nprim; ++i) {
|
||||
class_datum_t *cl = policydb->class_val_to_struct[i];
|
||||
for(constraint_node_t *n = cl->constraints; n ; n=n->next) {
|
||||
for(constraint_expr_t *e = n->expr; e; e=e->next) {
|
||||
for(constraint_expr_t *e = n->expr; e; e = e->next) {
|
||||
if(e->expr_type == CEXPR_NAMES) {
|
||||
if(ebitmap_get_bit(&e->type_names->types, typeId-1)) {
|
||||
if(ebitmap_get_bit(&e->type_names->types, typeId - 1)) {
|
||||
ebitmap_set_bit(&e->names, domain->s.value-1, 1);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,3 @@
|
||||
/* sepolicy.h - Header for magiskpolicy non-public APIs
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sepol/policydb/policydb.h>
|
||||
@@ -21,10 +18,12 @@ extern policydb_t *policydb;
|
||||
} \
|
||||
|
||||
// hashtab traversal
|
||||
#define hashtab_for_each(hashtab, cur, block) hash_for_each(htable, size, hashtab, cur, block)
|
||||
#define hashtab_for_each(hashtab, cur, block) \
|
||||
hash_for_each(htable, size, hashtab, cur, block)
|
||||
|
||||
// avtab traversal
|
||||
#define avtab_for_each(avtab, cur, block) hash_for_each(htable, nslot, avtab, cur, block)
|
||||
#define avtab_for_each(avtab, cur, block) \
|
||||
hash_for_each(htable, nslot, avtab, cur, block)
|
||||
|
||||
int create_domain(const char *d);
|
||||
int set_domain_state(const char *s, int state);
|
||||
@@ -32,5 +31,6 @@ int add_typeattribute(const char *domainS, const char *attr);
|
||||
int add_rule(const char *s, const char *t, const char *c, const char *p, int effect, int n);
|
||||
int add_xperm_rule(const char *s, const char *t, const char *c, const char *range, int effect, int n);
|
||||
int add_type_rule(const char *s, const char *t, const char *c, const char *d, int effect);
|
||||
int add_filename_trans(const char *s, const char *t, const char *c, const char *d, const char *o);
|
||||
|
||||
__END_DECLS
|
||||
|
Reference in New Issue
Block a user