Commit 91de7385 authored by topjohnwu's avatar topjohnwu

Whole new command-line

parent abaffc19
This diff is collapsed.
...@@ -115,14 +115,14 @@ void otherToSU() { ...@@ -115,14 +115,14 @@ void otherToSU() {
allow(ALL, "su", "process", "sigchld"); allow(ALL, "su", "process", "sigchld");
// uNetworkL0 // uNetworkL0
add_type("su", "netdomain"); attradd("su", "netdomain");
add_type("su", "bluetoothdomain"); attradd("su", "bluetoothdomain");
// suBackL6 // suBackL6
allow("surfaceflinger", "app_data_file", "dir", ALL); allow("surfaceflinger", "app_data_file", "dir", ALL);
allow("surfaceflinger", "app_data_file", "file", ALL); allow("surfaceflinger", "app_data_file", "file", ALL);
allow("surfaceflinger", "app_data_file", "lnk_file", ALL); allow("surfaceflinger", "app_data_file", "lnk_file", ALL);
add_type("surfaceflinger", "mlstrustedsubject"); attradd("surfaceflinger", "mlstrustedsubject");
// suMiscL6 // suMiscL6
if (exists("audioserver")) if (exists("audioserver"))
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <limits.h>
#include <string.h>
#include <sepol/debug.h> #include <sepol/debug.h>
#include <sepol/policydb/policydb.h> #include <sepol/policydb/policydb.h>
#include <sepol/policydb/expand.h> #include <sepol/policydb/expand.h>
...@@ -28,7 +30,7 @@ int load_policy(char *filename, policydb_t *policydb, struct policy_file *pf); ...@@ -28,7 +30,7 @@ int load_policy(char *filename, policydb_t *policydb, struct policy_file *pf);
void create_domain(char *d); void create_domain(char *d);
int add_file_transition(char *srcS, char *origS, char *tgtS, char *c, char* filename); int add_file_transition(char *srcS, char *origS, char *tgtS, char *c, char* filename);
int add_transition(char *srcS, char *origS, char *tgtS, char *c); int add_transition(char *srcS, char *origS, char *tgtS, char *c);
int add_type(char *domainS, char *typeS); int add_typeattribute(char *domainS, char *typeS);
int add_rule(char *s, char *t, char *c, char *p, int effect, int not); int add_rule(char *s, char *t, char *c, char *p, int effect, int not);
int add_typerule(char *s, char *targetAttribute, char **minusses, char *c, char *p, int effect, int not); int add_typerule(char *s, char *targetAttribute, char **minusses, char *c, char *p, int effect, int not);
int live_patch(); int live_patch();
...@@ -43,6 +45,16 @@ void enforce(char *s); ...@@ -43,6 +45,16 @@ void enforce(char *s);
void attradd(char *s, char *a); void attradd(char *s, char *a);
int exists(char *source); int exists(char *source);
// Vector of char*
struct vector {
size_t size;
size_t cap;
char **data;
};
void vec_init(struct vector *v);
void vec_push_back(struct vector *v, char* s);
void vec_destroy(struct vector *v);
// Built in rules // Built in rules
void su_rules(); void su_rules();
void min_rules(); void min_rules();
......
...@@ -395,7 +395,7 @@ int add_file_transition(char *srcS, char *origS, char *tgtS, char *c, char* file ...@@ -395,7 +395,7 @@ int add_file_transition(char *srcS, char *origS, char *tgtS, char *c, char* file
return 0; return 0;
} }
int add_type(char *domainS, char *typeS) { int add_typeattribute(char *domainS, char *typeS) {
type_datum_t *domain; type_datum_t *domain;
domain = hashtab_search(policy->p_types.table, domainS); domain = hashtab_search(policy->p_types.table, domainS);
......
...@@ -15,6 +15,28 @@ static void set_domain(char* s, int value) { ...@@ -15,6 +15,28 @@ static void set_domain(char* s, int value) {
} }
} }
void vec_init(struct vector *v) {
v->size = 0;
v->cap = 1;
v->data = (char**) malloc(sizeof(char*));
}
void vec_push_back(struct 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(struct vector *v) {
v->size = 0;
v->cap = 0;
free(v->data);
}
void allow(char *s, char *t, char *c, char *p) { void allow(char *s, char *t, char *c, char *p) {
add_rule(s, t, c, p, AVTAB_ALLOWED, 0); add_rule(s, t, c, p, AVTAB_ALLOWED, 0);
} }
...@@ -40,7 +62,7 @@ void enforce(char *s) { ...@@ -40,7 +62,7 @@ void enforce(char *s) {
} }
void attradd(char *s, char *a) { void attradd(char *s, char *a) {
add_type(s, a); add_typeattribute(s, a);
} }
int exists(char* source) { int exists(char* source) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment