Skip to content
Snippets Groups Projects
Commit c2b709e1 authored by Nick Kralevich's avatar Nick Kralevich Committed by Android Git Automerger
Browse files

am 893cfee5: am 7d090fbd: Merge "sepolicy-analyze: Change booleans command to...

am 893cfee5: am 7d090fbd: Merge "sepolicy-analyze:  Change booleans command to be more test-friendly."

* commit '893cfee5':
  sepolicy-analyze:  Change booleans command to be more test-friendly.
parents 4b334061 893cfee5
Branches
No related tags found
No related merge requests found
...@@ -56,9 +56,9 @@ sepolicy-analyze ...@@ -56,9 +56,9 @@ sepolicy-analyze
BOOLEANS (booleans) BOOLEANS (booleans)
sepolicy-analyze out/target/product/<board>/root/sepolicy booleans sepolicy-analyze out/target/product/<board>/root/sepolicy booleans
Displays the number of booleans defined in the policy. Policy Displays the boolean names in the policy (if any).
booleans are forbidden in Android policy, so if the output is Policy booleans are forbidden in Android policy, so if there is any
non-zero, the policy will fail CTS. output, the policy will fail CTS.
NEVERALLOW CHECKING (neverallow) NEVERALLOW CHECKING (neverallow)
sepolicy-analyze out/target/product/<board>/root/sepolicy neverallow \ sepolicy-analyze out/target/product/<board>/root/sepolicy neverallow \
......
#include "booleans.h" #include "booleans.h"
#include <sepol/booleans.h>
void booleans_usage() { void booleans_usage() {
fprintf(stderr, "\tbooleans\n"); fprintf(stderr, "\tbooleans\n");
} }
static int list_booleans(hashtab_key_t k,
__attribute__ ((unused)) hashtab_datum_t d,
__attribute__ ((unused)) void *args)
{
const char *name = k;
printf("%s\n", name);
return 0;
}
int booleans_func (int argc, __attribute__ ((unused)) char **argv, policydb_t *policydb) { int booleans_func (int argc, __attribute__ ((unused)) char **argv, policydb_t *policydb) {
int rc;
unsigned int count;
if (argc != 1) { if (argc != 1) {
USAGE_ERROR = true; USAGE_ERROR = true;
return -1; return -1;
} }
rc = sepol_bool_count(NULL, (const struct sepol_policydb *) policydb, return hashtab_map(policydb->p_bools.table, list_booleans, NULL);
&count);
if (rc)
return rc;
printf("%u\n", count);
return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment