xref: /aosp_15_r20/system/sepolicy/tools/sepolicy-analyze/perm.c (revision e4a36f4174b17bbab9dc043f4a65dc8d87377290)
1*e4a36f41SAndroid Build Coastguard Worker #include "perm.h"
2*e4a36f41SAndroid Build Coastguard Worker 
permissive_usage()3*e4a36f41SAndroid Build Coastguard Worker void permissive_usage() {
4*e4a36f41SAndroid Build Coastguard Worker     fprintf(stderr, "\tpermissive\n");
5*e4a36f41SAndroid Build Coastguard Worker }
6*e4a36f41SAndroid Build Coastguard Worker 
list_permissive(policydb_t * policydb)7*e4a36f41SAndroid Build Coastguard Worker static int list_permissive(policydb_t * policydb)
8*e4a36f41SAndroid Build Coastguard Worker {
9*e4a36f41SAndroid Build Coastguard Worker     struct ebitmap_node *n;
10*e4a36f41SAndroid Build Coastguard Worker     unsigned int bit;
11*e4a36f41SAndroid Build Coastguard Worker 
12*e4a36f41SAndroid Build Coastguard Worker     /*
13*e4a36f41SAndroid Build Coastguard Worker      * iterate over all domains and check if domain is in permissive
14*e4a36f41SAndroid Build Coastguard Worker      */
15*e4a36f41SAndroid Build Coastguard Worker     ebitmap_for_each_bit(&policydb->permissive_map, n, bit)
16*e4a36f41SAndroid Build Coastguard Worker     {
17*e4a36f41SAndroid Build Coastguard Worker         if (ebitmap_node_get_bit(n, bit)) {
18*e4a36f41SAndroid Build Coastguard Worker             printf("%s\n", policydb->p_type_val_to_name[bit -1]);
19*e4a36f41SAndroid Build Coastguard Worker         }
20*e4a36f41SAndroid Build Coastguard Worker     }
21*e4a36f41SAndroid Build Coastguard Worker     return 0;
22*e4a36f41SAndroid Build Coastguard Worker }
23*e4a36f41SAndroid Build Coastguard Worker 
permissive_func(int argc,char ** argv,policydb_t * policydb)24*e4a36f41SAndroid Build Coastguard Worker int permissive_func (int argc, __attribute__ ((unused)) char **argv, policydb_t *policydb) {
25*e4a36f41SAndroid Build Coastguard Worker     if (argc != 1) {
26*e4a36f41SAndroid Build Coastguard Worker         USAGE_ERROR = true;
27*e4a36f41SAndroid Build Coastguard Worker         return -1;
28*e4a36f41SAndroid Build Coastguard Worker     }
29*e4a36f41SAndroid Build Coastguard Worker     return list_permissive(policydb);
30*e4a36f41SAndroid Build Coastguard Worker }
31