diff --git a/tools/sepolicy-analyze/README b/tools/sepolicy-analyze/README index 6e3f83bb9d88785eee905064f6a71fe5b766a68e..0cb890b6d6d605fb1bfc956663ef0221f2690379 100644 --- a/tools/sepolicy-analyze/README +++ b/tools/sepolicy-analyze/README @@ -56,9 +56,9 @@ sepolicy-analyze BOOLEANS (booleans) sepolicy-analyze out/target/product/<board>/root/sepolicy booleans - Displays the number of booleans defined in the policy. Policy - booleans are forbidden in Android policy, so if the output is - non-zero, the policy will fail CTS. + Displays the boolean names in the policy (if any). + Policy booleans are forbidden in Android policy, so if there is any + output, the policy will fail CTS. NEVERALLOW CHECKING (neverallow) sepolicy-analyze out/target/product/<board>/root/sepolicy neverallow \ diff --git a/tools/sepolicy-analyze/booleans.c b/tools/sepolicy-analyze/booleans.c index 6533b8948876af93926c69f63be83e9a99ebae80..c3b605d0ab40a7ce5cc193cdf9b97af7e6c94d71 100644 --- a/tools/sepolicy-analyze/booleans.c +++ b/tools/sepolicy-analyze/booleans.c @@ -1,21 +1,22 @@ #include "booleans.h" -#include <sepol/booleans.h> void booleans_usage() { 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 rc; - unsigned int count; if (argc != 1) { USAGE_ERROR = true; return -1; } - rc = sepol_bool_count(NULL, (const struct sepol_policydb *) policydb, - &count); - if (rc) - return rc; - printf("%u\n", count); - return 0; + return hashtab_map(policydb->p_bools.table, list_booleans, NULL); }